#2052 - Formal implementation for cleanup of uploaded images

This is a spacer post for a website comment topic. The content this topic relates to: #2052 - Formal implementation for cleanup of uploaded images
adjust_pic_orientation (via constrain_gallery_image_to_max_size) is currently not being called for mass-uploaded gallery images. That should happen, but may need to happen in a task due to it being intensive.

It also won't be called if the image doesn't exceed the maximum size.

Also note this:
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.

Some research on file types...
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.

Some research on gamma correction for PNG files...

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');
I mostly have this implemented now, but I'm stripping off 2 parts to separate issues with I'm going to 'relate' to this issue...

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.
0 guests and 0 members have recently viewed this.