Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotate Image in Amazon S3

I have a bunch of images in Amazon S3 that I need to physically rotate. I currently do this by downloading the image to my server, rotating it using GD and overwriting it back to S3.

This process takes ~5 secs per image. I was wondering if there is any AWS API or such that can do this rotation directly in S3, preferably as in a batch mode?

I would appreciate it if anyone who has any experience with that kind of stuff can give me any pointers!

like image 255
Undefined Variable Avatar asked Dec 04 '15 18:12

Undefined Variable


People also ask

How do I rotate a picture on Amazon?

Click on the image to open it in Photo. When the picture is open, click “Edit”, “Crop and Rotate.” Rotate the photo as necessary, then Save. You'll be all set, quick and easy.

Is S3 good for images?

The more efficient and cost-effective option is to use AWS's S3 service for storing the image files. Using S3 is a very low-cost option. Effectively, all you are paying for is transferring files into an S3 bucket and serving those images to your users.

How do I know the orientation of an image?

The length of the longest side determines the orientation. For example, if the height of the image is longer than the width, it is a “portrait” format. Images where the width is longer are called “landscape.”


2 Answers

There is no way to rotate an image 'on' S3. Any method you employ is going to have to read the file from S3, do the rotation, and write it back to S3.

If the server you are doing it on now is not an EC2 instance, than its worth a try to do it there - the latency will be reduced quite a bit. Lambda is another option for you in that it will run within the AWS infrastructure, so network overhead will be reduced.

like image 79
E.J. Brennan Avatar answered Oct 04 '22 08:10

E.J. Brennan


Not quite sure what your constraints might be, but if you're preparing the images for a web page - you could rotate them client-side using CSS. That would prevent the additional calls to S3, and eliminate processing load on your application server.

img {
  transform: rotate(90deg);
}
like image 44
tim-montague Avatar answered Oct 04 '22 08:10

tim-montague