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

PNG image optimization #36

Open
FazlyMR opened this issue Aug 14, 2023 · 9 comments
Open

PNG image optimization #36

FazlyMR opened this issue Aug 14, 2023 · 9 comments

Comments

@FazlyMR
Copy link

FazlyMR commented Aug 14, 2023

I'm currently working on optimizing PNG images used for the website by lossy (not the JPEG kind) means of converting each from RGB to indexed colors, and reducing it's total unique colors to 1/3 of the original since it's going to be downscaled by the browsers anyway to a lower resolution, thus interpolating the colors lost by that lossy optimization process.

As a trial, I managed to trim off a total of ~128 KBs (kilobytes) from all 6 images used in chapter 1.

This is a sample of one of them:
syscall-architecture-differences-indexedlossy-o

And this is the unoptimized version currently used:
syscall-architecture-differences

Should I continue ahead and later submit a pull request for that?

@kognise
Copy link
Member

kognise commented Aug 15, 2023

I definitely want to optimize the images. Ideally this would be done automatically, however, perhaps with a script. Would you be interested in working on that?

@FazlyMR
Copy link
Author

FazlyMR commented Aug 16, 2023

Hmm, sadly I don't really have any coding/scripting experience (and no idea where to start to make that script to automate it and find the equivalent tools that I use)...

The way I did it is manually using GIMP, to convert from RGB to indexed colors and reduce the colors used, and ZopfliPNG (as part of Zopfli) as a last process to optimize the resulting PNG file itself.

@kognise
Copy link
Member

kognise commented Aug 16, 2023

No problem at all! I will look into it and see what I can do to replicate that process.

@FazlyMR
Copy link
Author

FazlyMR commented Aug 17, 2023

But in the meanwhile, would it be fine to submit a PR for my manual optimizations, which would still include the originals?

@FazlyMR
Copy link
Author

FazlyMR commented Aug 19, 2023

No problem at all! I will look into it and see what I can do to replicate that process.

After some searching, I did found a library/CLI program called pngquant that did the same things that I did manually (I also realized that what I did is to quantize the colors, didn't know that terminology before or I just forgot). Not sure how to automate it though.

@kariyum
Copy link

kariyum commented Aug 27, 2023

ffmpeg is a great tool to consider. It is possible to make a bash script that will take a directory as an input that is full of images and produce another one with the same images but compressed. ffmpeg is known to be very useful in image compresseion and especially in video compression with very low/unnoticeable loss in quality.

@haneenmahd
Copy link

I definitely want to optimize the images. Ideally this would be done automatically, however, perhaps with a script. Would you be interested in working on that?

You can use imgbot GitHub app to automatically optimise the images for you.

See GitHub marketplace: https://github.com/marketplace/imgbot

@kognise
Copy link
Member

kognise commented Sep 1, 2023

imgbot is great but i don't think it does as much as @FazlyMR was doing manually! would definitely be down to write a script.

@haneenmahd
Copy link

I'm interested in writing that script this weekend. If you had any ideas in your mind earlier about optimising it, can you brief it?

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

4 participants