-
Notifications
You must be signed in to change notification settings - Fork 121
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 Support #1835
Comments
Hello, @Reettaphant, @kenoir, Since I don’t know what would be best place to store some pseudo-research, I will keep it here unless told otherwise. Also, I don’t really know much about this, I may be wrong all the time. I definitely confuse terminology (alpha and transparency are not the same). PNGs come in different flavours and have to be treated and served differently because of that. We have to be able to identify these flavours using some image characteristics. We may even need to pass some of that to frontends for resizer needs (through CAPI?! 🙀). Here is a preliminary, not exhaustive list of things we will find useful (and which should be indexable/searchable):
Below I will try to see how GraphicsMagick 1.3.23 and ImageMagick 6.9.3-7 could help us here using
Observations/links:
Also: super-sorry for huge 🌵! Regards |
Hello, Just food for thought if we decide that we want to allow a “crisp graphic with no transparency” PNG “type” in Grid in addition to allowing “this should really be a JPG” and “cutout” types. Here is an image that would be a good candidate and exhibits characteristics specific to images of this class. The original in Grid currently is a JPG of 360KB (hash: d52ee9abe87d3168aba1d2cc1d41915a18927e58). Educating authors to supply similar images in PNG8 without transparency would allow for Grid to identify them easily as “graphic” type. But it will never be foolproof. This JPG with our current resizer settings produces unnecessary artifacts which is but one argument for being able to create a special pipeline for this type of images: Here is this same image converted to PNG24 (90KB): Same image is ~45KB as 256-colour PNG8 and still looks good as a 15-colour PNG8 of ~17KB when decided automatically by pngquant (could be used for final to-master conversion, should be compiled not to remove ICC profiles): There are two distinct problems if we decide to create a pipeline for similar graphic-like crisp imagery:
Ad. 1. If there is no transparency and the filetype is PNG8 we may quite safely assume that image was created with exactly this type in mind. We could introduce a filesize check if the master is too big and then push such image through “this should really be a JPG” pipeline instead (e.g. for photographs erroneously saved as PNG8).
Ad 2. There are two ways - either provide a compressed master (pngquant used similarly to above, probably) or pass on enough info to the frontend’s resizer to perform a compression on it’s own. My tests indicate that the second option would need to pass no. of output colours (15 here, which we wouldn’t have known without pngquant anyway) to be used for resizer’s Introducing this third type/class of images would mean that we would need to introduce a mechanism to pass information to frontends (beyond of relying simply on two distinct image extensions of JPG & PNG). I hope there is at least some use to the above. Regards |
Hello, Just testing cropping of TrueColor PNGs with alpha on TEST! @Reettaphant: Absolutely exceptional work! Wow! 16bpc works like a charm (master 8bpc), pngquant for crops! Grid's 317px crop (L) and original converted to sRGB from ProPhotRGB, resized (Bicubic Sharper) to 317px, saved as PNG24 in Photoshop, run through ImageAlpha (pngquant GUI) and ImageOptim (~4KB reduction) (R):
Couple of loosely connected points:
*pngquanted PNG thumb made manually from 316px crop: Regards |
@paperboyo Glad to hear it works! In response to your queries and comments:
|
Absolutely, may mean some slight speed reduction, but is more correct imaging-wise... We have recently reduced the size of our thumbs considerably (#1621, among others), PNGs aren't nearly as prevalent as JPGs - all this makes me think that we may decide it's more flexible to have them as pngquanted PNGs. But how this is affecting our setup - I wouldn't know. So if hard/impossible - there is a way to burn them into a background of our choice properly - I just forgot the GM command. And Slack has forgotten it too... |
Hello, Testing cropping of paletted PNGs with alpha... All is well. There is one small thing. The master crops (that do not go through pngquant) are bloated compared to original (if it’s optimised). They can be losslessly optimised. Example 5c8055055377ded723c241eb118b50f8c5dd9441: We may not care about it (since there is a resizer later on anyway). But we also may :-) Running masters through pngquant reduces the weight, but removes colour profile and introduces unnecessary changes to the pixel structure, since it’s a lossy process. I have not found a way to optimise them through GM only. Here are some alternative libraries (all output pixel-to-pixel identical to the original):
OptiPNG hasn’t produced substantial savings on the test file. PNGCrush hasn’t produced substantial savings on the test file. AdvPNG hasn’t produced substantial savings on the test file. CryoPNG hasn’t produced substantial savings on the test file. This is not proper test, as there is only one file (can’t upload from home). It’s entirely possible that on some other files the results would differ... And 5,6s for a file that small is a significant hit. Will keep looking... Regards |
Adjusting arguments to |
This is now (mostly) working, TagManager can start integrating Grid’s output and Grid itself*, @clloyd. Let me know if I can help in any way :-) *I think it would be very helpful, if an upload through TagManager’s instance of modal Grid could draw the metadata from TagManager itself, for instance. |
@paperboyo Yep! Offered it to anyone willing to take a stab at the TagManager codebase, if no one bites, then seems like a good flaw Friday project for myself. Lets continue discussion in guardian/tagmanager#233 |
Done. |
In order for use The Grid as an image source/picker in TagManager we need the ability to add .png files to the grid.
A standard contributor image is a transparent png (https://static.guim.co.uk/sys-images/Guardian/Pix/pictures/2014/3/13/1394733751535/ZoeWilliams.png)
The text was updated successfully, but these errors were encountered: