-
Notifications
You must be signed in to change notification settings - Fork 50
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
PNG file of smaller resolution is bigger than a smaller one? - size optimization mystery. #251
Comments
Hi, yes, compression is complex and depends on a lot of factors. Do you have some sample images which show this? |
png-mystery.zip |
Try
|
@jcupitt You are truly good at this ! :) |
@jcupitt I did performance testing on the receiving end of this data (google glass) - and it is a wonderful improvement. |
Oh, great! You could try turning off |
Yes, all my findings and actual use is compression=6 (which I suspect is the default) - it produces nice results. Also, I managed to run it fine on the Rpi. (the currently performance-limiting device) I do create one svg at a time (based on telemetry input), so it does not help to throw in multiple cores unless vips is multithreaded itself. |
libpng spends almost all of its time in deflate compression, so swapping libz out for something faster is an easy win. People usually suggest: |
Thank you. I will definitely have a look at it another day soon. |
@jcupitt I cloned, make, and make install the libdeflate library. (the speed is the same) |
Sorry, I've never actually done this. You might be able to symlink it to libz, or you might need to rebuild libpng. I'd look up some guides. |
For your information: While it sounded like a superb performance improvement, it does not seem to be very stright-forward, because I did a fast grep for libdeflate in vips's source, and it does not seem to have the API for it.(or at least does not mention the word "libdeflate") |
Oh darn, sorry, I though it was the same API. You should take a look at libpng -- that's what would benefit from using libdeflate. |
Thanks, let me get this right: |
That's it. libvips uses libz a little, but almost all the heavy use is inside the various format libraries. |
You could try to use zlib-ng. It's API / ABI compatible with zlib (when configured with fwiw, sharp uses this as the default zlib library in the pre-built libvips binaries since v0.28.0, so it might be worth experimenting with that. According to lovell/sharp#2604 this improves PNG de/compression performance by ~20%. |
@kleisauke Thank you.
...on a Rpi4 (need to build for arm, like I did libvips) I am not sure whatever your advice is that I use zlib-ng (and then recompile libvips, or somehow make it use zlib-ng) |
I'm not sure if the pre-built libvips binaries provided by sharp are compatible with pyvips (since I think the easiest way is to "just" compile zlib-ng from source with the flags mentioned above. By using the |
@kleisauke thank you. Could you please reveal the whole "LD_PRELOAD trick" ? I mean: what should this variable be set to? |
Please see: https://github.com/zlib-ng/zlib-ng#install. |
@kleisauke Thank you, that last one was embarrassing to overlook :) I'll report here any performance improvement/difference. |
Oddly, the zlib-ng is significantly slower:
At first I thought that it could be somehow just an overhead for the preload, but when testing a whole batch then the results are clear, - the libz-ng is much slower.
|
I need to transfer fast lots of images over a limited link. Color count is <10
When converting 553x288 svg to .png (compression=6), I had an average filesize of 36kB
then I reduced the resolution of the svg to 472x288 (trimmed off a black area)
now the average file size is 43kB.
Is png more efficient at some specific resolutions/aspect ratios? , when it can be divided by some specific number?
The text was updated successfully, but these errors were encountered: