Skip to content

StreamWrapper problems when handling images exported from Photoshop #1923

@Shebo

Description

@Shebo

Version of AWS SDK for PHP?

3.128.1

Version of PHP (php -v)?

7.2.3

What issue did you see?

The issue is with exported image files from Photoshop CC 2017 (Windows).
With the SDK, when trying to use getimagesize on a jpg image with custom stream wrapper (getimagesize( "s3://s3.eu-west-1.amazonaws.com/bucket-name/imagePhotoshopDuplicate.jpg" )) the function will return an error, but when using a standard stream wrapper (getimagesize( "https://s3.eu-west-1.amazonaws.com/bucket-name/imagePhotoshopDuplicate.jpg" )) the function will work as expected.

This issue is caused because Photoshop is adding some metadata headers to the original file upon export/save.

I don't know why exactly this is happening, but clearly the StreamWrapper is failing in handling these special headers. This looks like a bug with Photoshop but I think the StreamWrapper needs to know how to handle it.

Steps to reproduce

  1. Get an uncorrupted image from any source, duplicate it, import the duplicate to Photoshop CC 2017 Windows (maybe other versions will work too) and export/save it as a jpeg file.
  2. Upload the photoshop duplicate and the original image to an S3 bucket.
  3. Using the SDK, create an S3 client and register a custom Stream Wrapper (s3 will suffice).
  4. try to run getimagesize on both of the images with and without the custom stream wrapper. You can use the following code as an example:
var_dump(getimagesize( "https://s3.eu-west-1.amazonaws.com/bucket-name/imageOriginal.jpg" ));
var_dump(getimagesize( "s3://s3.eu-west-1.amazonaws.com/bucket-name/imageOriginal.jpg" ));
var_dump(getimagesize( "https://s3.eu-west-1.amazonaws.com/bucket-name/imagePhotoshopDuplicate.jpg" ));
var_dump(getimagesize( "s3://s3.eu-west-1.amazonaws.com/bucket-name/imagePhotoshopDuplicate.jpg" ));
  1. The getimagesize function will fail on the photoshop duplicate image when using the custom stream wrapper (showing an error about corrupted bytes), but the https will read it perfectly.
    6 (optional). Use a tool like ExifTool to compare the headers and metadata of the original image and the one exported by Photoshop.
    Run exiftool -all= imagePhotoshopDuplicate.jpg to remove all the headers from the Photoshop exported image, and then re-upload it to S3 and run the same tests again (as in step 4).
    You should now get a perfect result on all 4 tests.

Additional context

I found a closed issue from 2017 ( #1261 ) with exactly the same problem. The image that was uploaded to that issue was indeed an image with Photoshop CC 2017 (Windows) headers, it can be used for a test if there's no Photoshop CC 2017 software available.

I hope that now with enough evidence this issue can be solved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed-for-stalenessthird-partyThis issue is related to third-party libraries or applications.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions