sonata-project / SonataMediaBundle

Symfony SonataMediaBundle
https://docs.sonata-project.org/projects/SonataMediaBundle
MIT License
449 stars 496 forks source link

Resized images loose Exif-Data #1581

Closed philiplb closed 3 years ago

philiplb commented 5 years ago

Sonata packages

sonata-project/media-bundle

Subject

Resized images loose exif data like rotation information.

Steps to reproduce

I upload an image containing rotation information produced by the camera of a mobile device like a phone or tablet.

Expected results

The different image formats keep the meta data like the rotation.

Actual results

The different image formats loose the meta data like the rotation. The result is a correctly rotated original image but the different formats don't take the rotation into account anymore because the exif data is gone.

stale[bot] commented 4 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

lukepass commented 4 years ago

Hello, this issue is still relevant. When uploading images with Exif data the reference is keeping the option and the image is rotated. The generated thumbnails, instead, are not rotated and upside down.

Thanks.

core23 commented 4 years ago

Can you please give some more information? E.g the used resizer and image lib (imagick, gd, ...)

lukepass commented 4 years ago

Yes, of course! These are my contexts:

    profile_pictures:
        providers:
            - sonata.media.provider.image

        formats:
            big:   { width: 300 , quality: 85 }

For now I resolved by rotating and removing the metadata at the device (smartphone) level. But I think that the resizer should honor the exif rotate metadata.

Do you need more information?

Thanks.

core23 commented 4 years ago

IMHO it's a bug in https://github.com/avalanche123/Imagine, but feel free to investigate a little more to solve this issue.

lukepass commented 4 years ago

Following this issue: https://github.com/avalanche123/Imagine/issues/190

It seems that they included an Autorotated class which should rotate the image automatically. The problem lies in the thumbnail generation?

core23 commented 4 years ago

It's a filter that does the rotation. You should include this in your config

lukepass commented 4 years ago

Could you please provide a little sample about this? How can I include a filter in the config? How is the filter called?

wbloszyk commented 4 years ago

https://sonata-project.org/bundles/media/3-x/doc/reference/advanced_configuration.html

sonata_media:
    default_context: default
    admin_format:   { width: 200 , quality: 90, format: 'jpg'}
    contexts:
        default:  # the default context is mandatory
            download:
                strategy: sonata.media.security.superadmin_strategy
                mode: http
            providers:
                - sonata.media.provider.image

            formats:
                small: { width: 100 , quality: 70}
                big:   { width: 500 , quality: 70, resizer: sonata.media.resizer.square}
                # You can pass through any custom option to resizer by using the resizer_options key
                icon:  { width: 32, quality: 70, resizer: your.custom.resizer, resizer_options: { custom_crop: true } }

SonataMediaBundle contains:

Add own resizer:

Optional you can add the same arguments like sonata resizers by add arguments:

lukepass commented 4 years ago

Thanks for the example @wbloszyk, I am already using a custom resizer in my application but I don't know where can I use the autoresizer filter in it. Thanks!

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

lukepass commented 3 years ago

Hello, the issue has been closed but the problem is still present. Thanks.

VincentLanglet commented 3 years ago

There was no activity during 6 months, and when I look at answers

IMHO it's a bug in https://github.com/avalanche123/Imagine, but feel free to investigate a little more to solve this issue.

It's a filter that does the rotation. You should include this in your config

It's seems not related to SonataMedia.

But if I'm wrong, feel free to explain why and PR is welcomed.