Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add option to put converted png files in a specific directory to avoid redundant conversions #246

Open
xuwei152 opened this issue Nov 22, 2024 · 1 comment

Comments

@xuwei152
Copy link

Problem Description

The current implementation of image.nvim converts non-PNG files (e.g., SVG) to PNG when opening Markdown files. This freezes my neovim when there are many SVG files, as the conversion happens every time Neovim starts.

Proposed Solution

Introduce an option to specify a custom directory for storing converted PNG files. This option will:

  1. Allow users to set a directory (e.g., ~/Trash/imageConvert) for all converted files.
  2. Before converting a non-PNG file to PNG:
    • Check if a converted PNG file already exists in the specified directory.
    • If the file exists, load the cached PNG file instead of re-converting.
    • If not, convert the file and save it to the specified directory with an appropriate name.

This may improve performance by avoiding redundant conversions.

my hard-coded solution

I have already implemented a hard-coded solution by modifying lua/image/image.lua, but I am looking forward to a more elegant and configurable implementation."

image

@xuwei152 xuwei152 changed the title Feature request: add option to put converted file in a specific directory to avoid redundant conversions Feature request: add option to put converted png files in a specific directory to avoid redundant conversions Nov 23, 2024
@3rd
Copy link
Owner

3rd commented Dec 5, 2024

Agree it's an issue, wondering how to handle the last modified checks.
Some users need the images to be reloaded if they change externally, and I'm not sure if the lazy way dir/{name}_{last_modified}-source.png
What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants