Zola: Low quality of resized images

Created on 2 Dec 2018  路  12Comments  路  Source: getzola/zola

Currently, all resized images are JPEG (according to docs), which doesn't really work well with computer-generated images, such as screenshots. There is also no transparency which makes it even worse.

For example, the following image
orbtk-calculator
becomes (at 100% quality)
70659a75198d41ac00

Any way to create PNGs in the future?

done

Most helpful comment

image AFAIK does support encoding of PNGs, so that sould not be a problem. As for preserving the format, I'm not sure you'd really want to do that. For example, making a bmp thumb for a bmp image doesn't make much sense to me, you most likely want png. Perhaps the best way would be to create jpgs for lossy formats and png for lossless formats.

I think the best way would be to have a format option with possible choices "auto" (which would do the above), "png" and "jpeg", defaulting to "auto". Should not be difficult to implement...

All 12 comments

Looks like it should keep jpeg/png if possible yes.

I'd be willing to try working on this, but beware: I'm a Rust beginner with a day job as a PHP developer. :smiley:

I was thinking of a possible implementation in two steps: the resize_image function should keep the format of the images it's fed by default, so if I try to process a PNG it'll keep the format. As a second step, we could add an optional argument to resize_image that specifies the desired extension, like ext=jpg.

Thoughts?

Go for it!
What you said does make sense to me, although I don't know the support of images outside of jpeg in Rust :/

cc @vojtechkral who wrote the original code for feedback as well.

I'll look at the image crate and we'll see if something can be done then!

image AFAIK does support encoding of PNGs, so that sould not be a problem. As for preserving the format, I'm not sure you'd really want to do that. For example, making a bmp thumb for a bmp image doesn't make much sense to me, you most likely want png. Perhaps the best way would be to create jpgs for lossy formats and png for lossless formats.

I think the best way would be to have a format option with possible choices "auto" (which would do the above), "png" and "jpeg", defaulting to "auto". Should not be difficult to implement...

I agree with @vojtechkral
Having options jpeg, png and auto (with default to auto) would be really nice.

Btw. what's with the project rename? :) I must've missed that. Should we also replace pictures of Gutenberg with those of 脡mile Zola in the documentation? :)

Explained here: https://www.vincentprouillet.com/blog/releasing-zola-0-5-0/#a-bit-of-history-and-changing-name-to-zola

No need to change the pictures

@vojtechkral I like this implementation, that's in the same general direction of what I was going for, just more polished :grin:

The essential problem here is not, so far as I understand it, the encoding, but rather the resize filter. Gaussian, which is what is currently used, is producing unexpected blur. For reducing image size, which I believe is the common use case being targeted, Lanczos3 will almost always produce better results (certainly sharper). Switching should be a one line fix.

I just ran some tests, and changing the filter doesn't seem to have made a whit of difference, but I could have done it wrong.

I created a pull request. The same thumbnail using PNG looks like this:

d65da6df13fee0b000

Transparency seems to be preserved as far as I can tell.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Keats picture Keats  路  7Comments

upsuper picture upsuper  路  3Comments

nikhiljha picture nikhiljha  路  5Comments

codesections picture codesections  路  5Comments

porglezomp picture porglezomp  路  7Comments