-
Notifications
You must be signed in to change notification settings - Fork 658
perf!: faster image preview with optimized magick arguments
#2533
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
Conversation
|
That's incredible! Can you explain to me the reason for each parameter change? |
|
The order of some options is crucial, for example, Edit. I was wrong about the |
|
Moving You can download and |
|
I actually checked this during testing. I didn't notice that one layer was missing. Sorry about that.
|
|
Maybe add a Then receive it with So that we don't have to incur ongoing performance loss for all image formats, since images with multi-layer didn't seem very common |
|
Awesome. Unfortunately, I will need assistance with this, or some time to figure out how to implement it, since learning Lua is still only in my plans. By the way, I noticed that rust previewer does not create thumbnails on hover when the preloader is disabled. Is this an intended behavior? |
No worries, I'll take care of it
What's rust previewer? You mean |
magick argumentsmagick arguments
Awesome. Thank you!
|
|
I was wrong again. Edit. |
magick argumentsmagick arguments
Yes, this is expected,
Should be fixed now in the latest commit – changed back to |
sxyazi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
|
Correct me if I'm wrong, but Edit. Source file: https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/car.svg |
|
In my tests, not adding Original SVG: With
|
|
Oops, I passed two different |
|
Edited #2533 (comment) with the same |
|
Because you are up-scaling the bitmap with |
That's intentional, SVG is a vector format, which means it doesn't have a fixed width or height, and its initial canvas size can be very small, which makes it less ideal for previewing. I'll test |
|
@sxyazi Maybe it would be better to switch to Also, rendering with resvg would be significantly faster. |
No luck, |
I haven't looked into |
I understand. I thought we desired the original size when the source is smaller than the thumbnail. In this case just the
Strange, here it looks like this. Edit. Looks like we can drop |
It is cross platform but not sure that they have some widget pakage. In any case, I will try to prepare the PR and then we will see the binary size impact |
Yes, for raster graphics formats we will respect their original size, but the vector format is an exception because its dimensions are the design dimensions rather than the used dimensions. Do you think it would be more reasonable not to scale up — why? Perhaps we can discuss changing this behavior.
I revalidated that the parameters were correct and tested it, but the result is the same. I also tried using just |
I don't have a strong opinion on the subject. Up-scaling probably makes more sense, especially when previewing very small files, for example 16x16 icons. Anyway, looks like Maybe |
|
I installed ImageMagick with Homebrew, and seems it doesn't depend on |
|
It'a a build dependency, but I'm only speculating. Perhaps it would be sensible to pass the arguments via config file with safe-ish defaults? And similarly, regarding the scaling method for raster files. Edit. Looks like Edit2. Bingo. Without |
|
A tip for those who are not satisfied with the quality of
|
Yeah, if someone needs them, we can add it as a previewer parameter, but of course, that would need to be justified — like obvious visual differences between
Great find! Since the current SVG previewer uses I just tested it, and it seems that for ImageMagick builds that don't support OpenCL acceleration, it silently ignores it, so it doesn't seem to break anything. |
|
Here's an example when Personally, I think this quality is perfectly fine for this job, but there will certainly be people who disagree. An alternative approach: use I believe Yazi should require main +
|
Yeah, I plan to explore other ImageMagick alternatives in the future for SVG rendering |
…#2533) Co-authored-by: sxyazi <[email protected]>












This should noticeably speed up previews and thumbnail generation when using
magick. Also, the size of the thumbnail files should be smaller, especially when images have a landscape orientation.Some numbers:
AVIF
Before:
After:
HEIF
Before:
After:
JPEG XL
Before:
After:
New
svgplugin as the previewer, preloader, and spotter for SVG filesUnlike typical image formats, SVG is a vector format.
This PR separates it from the
magickand moves it into a newsvgplugin, so that SVG-specific parameters do not affect magick's performance, and magick-specific parameters do not affect SVG's performance, thus improving the performance of both.This also makes it possible in the future to migrate the SVG backend from
magickto other more specialized tools (such asresvg) without affecting themagickplugin –magickrenders certain SVGs incorrectly and has suboptimal performance.Disable the
-flattenparameter formagickby defaultThe
-flattenparameter is used to support multi-layer images, but it has a significant impact on performance, and multi-layer images are not common across all image formats.A new
--flattenhas been introduced to enable it manually: