Closed LintaoAmons closed 5 months ago
Thanks for reporting. I think the best solution here is to allow the user to specify a custom preprocessing command (i.e. a command that is executed before the image is embedded or saved). This would involve adding the following option:
preprocess_cmd
(string, default: nil
): Specifies a custom command to preprocess the image before saving or base64 encoding. The command should accept the image file path as input and output the processed image to stdout. For example, to use ImageMagick for compression: "convert -quality 75 - -"
.This should bring full flexibility to the user. Thoughts on this @LintaoAmons?
Yeah! Definitely better
I think providing user some sample functions would help a lot. People like me don't familiar with how to deal with pictures, so it would be very kind of you
I've implemented this in the feat/process-cmd
branch. You can set the branch
option in lazy.nvim and update to try it out. Set the process_cmd
option to try it out.
Your config should look like this:
default = {
embed_image_as_base64 = true,
process_cmd = "convert -quality 85 - -",
},
@LintaoAmons How is this working out for you? If you face issues please post the output of the :ImgClipDebug
command.
I'm trying to test on my machine, but I'm facing some errors.
I have tried the main branch and also revert to previous commit, the issue still exists. So I think there's something went wrong with my laptop instead of this plugin.
***%20Error%20creating%20a%20JP2%20color%20space:%20falling%20back%20to%20sRGB
do you have any hints of this error?
Seems like an unrelated issue, yes. Can you switch to the main branch for now and open a new issue?
In the new issue, please post your config, OS and output of ":ImgClipDebug" after the error occurs. Also, try disabling base64 embedding and see if the error persists.
I think most of the case, we don't need high quality img in our markdown file, as along as the content is readable.
So if we can have one more option to compress the image before save it as base64 format into the markdown file.