-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
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
- 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.
- Upload the photoshop duplicate and the original image to an S3 bucket.
- Using the SDK, create an S3 client and register a custom Stream Wrapper (
s3will suffice). - try to run
getimagesizeon 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" ));
- The
getimagesizefunction 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.
Runexiftool -all= imagePhotoshopDuplicate.jpgto 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.