-
Notifications
You must be signed in to change notification settings - Fork 42
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
Refactor the processImages, optimizePngs and optimizeJpegs transforms #35
Comments
It's obvious that we should refactor the optimization transforms to use the new stream based libraries. I also very much like the idea of not having to rerun optimizations in case some of them have already been applied in an explicit step earlier. Running all those optimizations is heavy work, and the less we do of it the better. |
On the idea of merging all of these steps into one I am not quite certain it is a good idea. Mostly because is the intermediate spriting step. If we find a way to make that fit in there seamlessly I think it's a good approach. |
It's mostly because of the need to avoid rerunning the optimizations that I think it should be one step. I've tried very hard to avoid maintaining any shared state between the transforms. Maybe a compromise could be to rely on the suffixes that are already added to the file names of the images that have been processed by Wrt. the spriting, yeah. You might want to process an image before it's sprited and process the sprite itself afterwards. Maybe running |
How about something like this? One-com@e041bb7 Not yet implemented assumptions:
|
This is great! Given those assumptions the only thing left I can think of is spriting post processing instruction conflict handling that might cause usability issues with developers. I think we can put it in the wild without a clear strategy on that single issue though. It doesn't seem to be a widespread use case given that not many people are even aware if the spriting ability. Also this solution doesn't do any worse than the previous one with vendor specific css properties, where you could also add post processing conflicts. |
I'm not exactly sure what you mean by "spriting post processing instruction conflict handling"? But yeah, we need to invent syntax for specifying what is to be done to the sprite after it's generated. This would be sufficient: .icon {
-ag-selector-for-group: icons;
-ag-sprite-query-string: pngquant=40&optipng=-o7;
} But it might be cooler to mirror the syntax for .icon {
-ag-selector-for-group: icons;
-ag-sprite-background-image: url(mySprite.png?pngquant=40&optipng=-o7) !important;
} Then AssetGraph-sprite could just promote Hmm, maybe it'd even be possible to strip the .icon {
-ag-selector-for-group: icons;
background: red url(?pngquant=40&optipng=-o7) !important;
} |
Ok, That leaves this as my preferred option: .icon {
-ag-selector-for-group: icons;
-ag-sprite-background-image: url(mySprite.png?pngquant=40&optipng=-o7) !important;
} |
How about vendor prefixed selectors? -ag-sprite spriteSheetName {
selector: icons;
background: url(pngquant=40&optipng=-o7);
} I haven't tried this. But is seems better to me if we can make a css block per sprite sheet and use that to specify post processing and other specific sheet relevant sprite options. If my intuition is right, browsers should ignore all of this, since the selector is unknown. Thus not adding any problems with the invalid background url. |
Hmm, interesting... Although part of the idea is that additional properties in the group selector should get applied in "development mode", like: .icon {
float: left;
-ag-sprite-selector-for-group: icons;
[...]
} ... and in the example with So it's really only the url that's the problem. Maybe we should bite the bullet and add that .icon {
-ag-sprite-selector-for-group: icons;
-ag-sprite-url: allIcons.png?pngquant=256;
background: red !important;
} ... which would compile to (again, the file name part could be omitted): .icon {
background: red url(allIcons.png?pngquant=256) !important;
} We would still get rid of |
Yeah, I'd like to see how many of the vendor specific properties we can live without. And if that frees up something, maybe shorten the ones left over. |
All right! I guess it has to be |
The only thing I don't like about that is the property naming. We could also drop using |
Implemented The custom CSS property previously known as
About switching from |
Seems to me that every source images modifications can be expressed through the GET parameter chain, which then ends in an optional sprite call. The only reason sprites need this css block is that they don't have reference to define a similar chain of parameters to. So given this assumption is true, only the sprite specific stuff needs vendor prefixed css properties. I don't know what |
.mySprite {
-ag-sprite-group-selector-for: mySprite;
}
.foo {
background-image: url(foo.png?sprite=mySprite);
}
.bar {
background-image: url(bar.png?sprite=mySprite&spriteNoGroup);
} ... which becomes: .mySprite {
background-image: url(123.png);
}
.foo {
background-position: 0 0;
}
.bar {
background-image: url(123.png);
background-position: -20px 0;
} This is for scenarios where you can't guarantee that an element is matched by both |
Dropped |
Landed on master in f42572a. |
Can't wait to try all of this out. It seems like a massive improvement and simplification. |
Yeah, I've only played a little with it in LiveStyle, but it seems very powerful and flexible. |
Deprecated |
…ge with a GET parameter called 'inline'. See discussion here: https://github.com/One-com/assetgraph-builder/issues/35
Ideas:
pipeImageThroughChildProcessAndBuffer
thing.transforms.optimizePngs
andtransforms.optimizeJpegs
shouldn't kick in if the same tool is already specified explicitly in the query string.@Munter, what do you think?
The text was updated successfully, but these errors were encountered: