-
Notifications
You must be signed in to change notification settings - Fork 967
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
Oxipng #1685
base: next
Are you sure you want to change the base?
Oxipng #1685
Conversation
fixed an accidental deletion part of syntaxhighlighting link
# Conflicts: # Cargo.lock
1e55db1
to
3155662
Compare
https://github.com/shssoichiro/oxipng for people other than me not knowing what it was. I'll have a look at this PR as soon as the next bugfix version is released |
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.
I think the optimization should be run before copying the assets so it happens only once but it means it would overwrite the existing file but I'm not sure how to recognize that a file has already been processed other than keeping some state file or something.
@@ -1127,6 +1128,18 @@ impl Site { | |||
}) | |||
.collect::<Result<()>>() | |||
} | |||
|
|||
/* | |||
when running serve we do not want png optimizations, because that's too slow. |
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.
This should only ever ran once for a file, after that it should be stored in static
like the rest of the image processing so it's ok to run it on serve
/// Whether to optimize png files | ||
pub optimize_png: bool, | ||
/// level to optimize png files if applicable | ||
pub optimize_png_level: u8, |
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.
I believe this field can be an Option<u8>
and you remove the need for optimize_png
Hi @Keats, I agree it would be nicer if a file would only have to proces a file once. But then we would need some way of keeping track of which files are already processed and which not. I'm not sure if that would be worth the effort. It opens a whole can of worms, maybe it would be better to use webp with png as a fallback. |
Yeah I'm not too sure what to do honestly... Re-processing the files everytime is not great and you probably want to at least see what they look like on
Probably. Some simple json file or whatever that just stores a list of transformation/input and their hashes to see if anything is needed. Code wise, it would be a bit more complicated but not much more so. I expect there will be other transformations that will be needing the same kind of check, I think? |
From what i understand from your comment is that optimized png's, the assets, would have to be under source control as well. So I'm not sure we should proceed with this. It seems to add more complexity than that it adds value. I dont think it's worth it in this form. |
Do you mean you want only the source one or also the generated ones? |
in my case i have just one image version under source control. during should you put the generated under source control then you could end up with lots of obsolete images in git, that you would have manually remove from the static\processed_images folder |
It would be really surprising to me if the generated images were under source control. |
It's already the cases with resized images |
Consider me surprised. 😅 |
To be fair they are all put in the same folders so you can gitignore it if you want. |
The folder for resized images is always in my gitignore file. But then any administration you keep about files being optimized becomes irrelevant, because these files are generated and, if configured, optimized on every build. |
oxipng is fast! so happy I found this pull request so I could learn of this tool! |
If I may, it seems more appropriate to me to store the images separately (e.g. in a This takes care of the "have the images been processed already?" question, while already integrating nicely with the existing workflow/model (if you modify the source image but forget to compress it, then it will simply not update in the render, which should immediately signal that something is wrong. This also lets the user pick the optimisation settings that work best for them. (I've opted for the most aggressive settings since I'm only doing this once, but that's really slow.) Also, on my personal website, I have PNGs, but also JPEGs and SVGs, which need to be processed by other tools. 1 (Tools list sourced from Squoosh.) The obvious downside is a lack of discoverability; this could be solved by adding a page to the docs, I think. Footnotes
|
8b1a413
to
67c2fe0
Compare
IMPORTANT: Please do not create a Pull Request adding a new feature without discussing it first.
The place to discuss new features is the forum: https://zola.discourse.group/
If you want to add a new feature, please open a thread there first in the feature requests section.
Sanity check:
Code changes
(Delete or ignore this section for documentation changes)
next
branch?If the change is a new feature or adding to/changing an existing one:
Updated my oxipng branch with latest changes from next. new pull request of the addition of configurable png optimization to zola.