#2052 - Formal implementation for cleanup of uploaded images
| Identifier | #2052 |
|---|---|
| Issue type | Feature request or suggestion |
| Title | Formal implementation for cleanup of uploaded images |
| Status | Completed |
| Tags |
Type: Usability (major) (custom) |
| Handling member | Chris Graham |
| Addon | core |
| Description | When images are uploaded, put them through a cleanup pipeline:
- Fix image rotation, so EXIF-unaware browsers don't struggle (currently exists, make it an option) - Apply extra lossless compression to images (only if a optipng path is configured, and it should be autodetected by the option if it is available) - Convert non-websafe image formats if Imagemagik is available (psd files, bmp files, tiff files) [image upload fields will need to then be allowed to take in these file types] - Fix gamma issues (if we can do this? Also make it an option) - Resize to specific required size (option: auto-resize if needed) - Resize to maximum size |
| Steps to reproduce | |
| Funded? | No |
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".


Comments
It also won't be called if the image doesn't exceed the maximum size.
https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation
https://www.w3.org/Bugs/Public/show_bug.cgi?id=25508#c27
https://bugs.chromium.org/p/chromium/issues/detail?id=158753
Firefox has implemented, nobody else has. Chrome is arguing it is standardised badly, and possibly pushing to make it default to on and possibly make it controlled via an HTML attribute.
I think the only non-websafe formats we don't currently support are:
- BMP
- TIFF
BMP will be supported in v11, as it was added to PHP recently (for PHP builds that support it). It's not very important though as MS Paint has used .png as the default file type since at least Windows 7.
TIFF is not web-safe, and not supported by GD. And it is used widely in cameras. It would be nice to be able to auto-convert that.
I don't think any people are going to casually upload PSD files and expect them to display.
Gamma shows worse in:
- All versions of Safari (up to Safari 11.1, the latest)
- IE9 and lower
Firefox, Chrome, and IE10+ seem generally consisten with each other.
I don't think they ignore gamma, but they interpret it differently (cumulative vs ignore vs override?). It's hard to say what is correct.
There are 2 issues:
1) Inconsistency between browsers
2) Inconsistency between CSS colours and image colours, which are meant to be in the same colour space
There's a good test image in:
https://superuser.com/questions/579216/why-does-this-png-image-display-differently-in-chrome-firefox-than-in-safari-a
On Mac, Preview shows the same as Safari. Pixelmator shows the same as Firefox/Chrome/IE10+.
The best solution is to just strip gamma, as it's unlikely we even care about the system gamma saved into an image.
Just opening and resaving the image in PHP/GD effectively strips the gamma:
$img = imagecreatefrompng('VhGrd.png');
imagepng($img, 'VhGrd3.png');
1) support other uploaded formats and convert via Imagemagik (bmp, tif/tiff)
2) optipng heavy compression for PNG files
I don't actually care about these things, and they'd add a fair amount of extra work.