Exif Rotation

Permalink
I see this info about enabling image rotation by reading the exif data from the image..
experimental, toggle on by enabling with the config value concrete.file_manager.images.use_exif_rotation_data

Can someone shed some light on how we enable this in 5.7?

ConcreteOwl
 
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
I found what I think is the config file at concrete/config/concrete.php and had a hack at the code but no joy!
Here is the default code
'file_manager' => array(
        'images' => array(
            'use_exim_data_to_rotate_images' => false, // tried setting this to true but no luck
            'manipulation_library' => 'gd'
        ),
        'results' => 10
    ),


Has anyone ever managed to get exif data rotation working in a concrete 5 site?
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Has anyone ever managed to get exif data rotation working in a concrete 5 site?
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi weyboat,

I just tested toggling the use_exim_data_to_rotate_images setting and it works.

This is the image I tested with:
https://raw.githubusercontent.com/recurser/exif-orientation-examples...

Steps to test:
- set use_exim_data_to_rotate_images to true
- upload the test image
- the image is rotated in the preview and when viewing the image (the waterfall is vertical)
- set use_exim_data_to_rotate_images to false
- upload the test image again
- the image is not rotated in the preview or when viewing the image (the waterfall is horizontal)

It looks like this setting affects images when they are uploaded and processed.
https://github.com/concrete5/concrete5/blob/5.7.x/web/concrete/src/F...
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Hi MrK
These are the exact same steps I tried already.
I have tried again using the same image that you used and with the setting set to true, I still get a horizontal waterfall?
I have checked that I have the php_exif extension enabled and it is.
Am I missing something else here?
EDIT
I have also tried this on a different server - same result..
EDIT No2
I have checked my php.ini file and can confirm the following is present
extension=php_mbstring.dll
extension=php_exif.dll ; Must be after mbstring as it depends on it
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
I have tried this on a local dev machine running concrete5.7.5.13 and on a fresh install of concrete5.8.1.
Also tried on a live server running concrete5.7.5.13.
Just cannot get it to work..
MrKDilkington replied on at Permalink Reply
MrKDilkington
@weyboat

My successful test was on a local server using concrete5 version 5.7.5.9 and 5.7.5.13 using XAMPP on Windows 7.

Using the same setup, I tested using with concrete5 version 8.1.0 and it threw an error:
Upload Failed
Portrait_6.jpg
Saving image in "" format is not supported, please use one of the following extensions: "gif", "jpeg", "png", "wbmp", "xbm"

- Renaming the filename and file extension did not resolve the error.

It looks like the config key was renamed in v8.0.3:
https://github.com/concrete5/concrete5/commit/acf9afbf8a7a08bf534680...
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
@MrKDillkington
I had the same error thrown in 5.8.1 until I set the Image Uploading settings in dashboard/system/files/image_uploading, (I used the sizes displayed in the placeholder text).
This allowed the image to upload, but did not rotate it?
MrKDilkington replied on at Permalink Reply
MrKDilkington
@weyboat

I did a quick test and EXIF metadata is not preserved when using the client side image resizing.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Yes, its almost as if this should be performed in two separate operations.
1. Rotate and save the image..
2. Resize the rotated image..

EDITED
MrKDilkington replied on at Permalink Reply
MrKDilkington
@weyboat

This pull request was just accepted:
"Autorotate image on upload based on Exif Metadata"
https://github.com/concrete5/concrete5/pull/4820...
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
I just tried to implement this on 5.7 and 5.8, it throws errors in 5.7.
In 5.8, no errors but it still does not work if the 'Resize Images On Upload' is set to on..

I will continue to fiddle with it to see if it can be made to work..

Thanks for the heads up.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Progress!
In 5.8.1 I switched the processing so that the rotation was called before the resize.
in the Importer.php file.
Before
public function __construct()
    {
        $resize = Config::get('concrete.file_manager.restrict_uploaded_image_sizes');
        if ($resize) {
            $width = (int) Config::get('concrete.file_manager.restrict_max_width');
            $height = (int) Config::get('concrete.file_manager.restrict_max_height');
            $quality = (int) Config::get('concrete.file_manager.restrict_resize_quality');
            $resizeProcessor = new ConstrainImageProcessor($width, $height);
            $qualityProcessor = new SetJPEGQualityProcessor($quality);
            $this->addImportProcessor($resizeProcessor);
            $this->addImportProcessor($qualityProcessor);
        }
        if (Config::get('concrete.file_manager.images.use_exif_data_to_rotate_images')) {
            $this->addImportProcessor(new AutorotateImageProcessor);
        }

After switching
public function __construct()
    {
        if (Config::get('concrete.file_manager.images.use_exif_data_to_rotate_images')) {
            $this->addImportProcessor(new AutorotateImageProcessor);
        }
        $resize = Config::get('concrete.file_manager.restrict_uploaded_image_sizes');
        if ($resize) {
            $width = (int) Config::get('concrete.file_manager.restrict_max_width');
            $height = (int) Config::get('concrete.file_manager.restrict_max_height');
            $quality = (int) Config::get('concrete.file_manager.restrict_resize_quality');
            $resizeProcessor = new ConstrainImageProcessor($width, $height);
            $qualityProcessor = new SetJPEGQualityProcessor($quality);
            $this->addImportProcessor($resizeProcessor);
            $this->addImportProcessor($qualityProcessor);
        }


This appears to be working in 5.8.1

Onwards...