Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chimit's avatar

How to get EXIF data from an image on S3?

I use AWS S3 to store images and the Intervention Image package to manipulate them on downloading:

$source_file = Storage::disk('s3')->get($filename);

$file = Image::make($source_file)
                ->orientate()
                ->fit(200, 200, function ($constraint) {
                    $constraint->upsize();
                })
                ->encode(null, 80);

Everything works well except of one case: if the original image is a vertical photo from an iPhone the resized version is 90 degrees rotated. Apparently, it's because iPhone uses some EXIF parameters to indicate orientation and these parameters are ignored by the Intervention Image orientate() method.

This returns nothing:

$source_file = Storage::disk('s3')->get($filename);

info(Image::make($source_file)->exif());

Intervention Image package documentation says:

Image object must be instantiated from file path to read the EXIF data correctly.

But I have no idea how to do it with S3. So the final questions sounds like how to get an image from S3 with EXIF information?

0 likes
8 replies
Nash's avatar

How are you storing the image to S3, is the EXIF data really passed along or are you creating a new image? Try using ->orientate() when storing/uploading the image instead of during download.

chimit's avatar

I upload original files to S3 without any manipulations. I'm afraid if I orientate an image on uploading all other EXIF data like GPS may be lost.

tinfoilman's avatar

Has anyone figured this out? I'm having the same problem and it's a serious problem. I can't have my member's photos showing up sideways.

dgiakoum's avatar

Bumping this, as I'm facing a similar issue working with base64 images. Here's my test on it which results in a wrong orientation of the image:

        $base64_image = (string) Image::make('Landscape_3.jpg')->encode('data-url');
        $img = Image::make(file_get_contents($base64_image))->orientate()->encode('webp')->save('output-base64.webp');

Whereas if I read the image off of the filesystem directly reorientation works

$img2 = Image::make('Landscape_3.jpg')->orientate()->encode('webp')->save('output-file.webp');
Cien02's avatar

exif_read_data(Storage::disk("s3")->readStream("MyImage.jpg"));

vpuentem's avatar

I'm having the same issue uploading files to S3, The original file is correctly set but when i manipulate it using InterventionImage, the conversions get rotated, i tried using the orientate() method but apparently the metadata from the original image is lost after uploading it

Snapey's avatar

@vpuentem The exif data is lost when you manipulate it and store it as a new image.

I've had this problem in the past, and it was never to do with exif. The customers were taking overhead shots of items for a sales listing. With the phone laid flat it has no concept of 'up'. The solution was to show a preview and let the user rotate the image.

1 like
vpuentem's avatar

@Snapey been losing my mind over this all day. Actually the exif data is correctly set in the file in S3 but when loading it to InterventionImage using the Image::make() method and logging the exif data of the loaded image it does not returns the correct one :(

Guess I'll go with the user preview approach, thanks for the reply!

Please or to participate in this conversation.