Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get image height and width of image stored on Amazon S3

I plan to store images on Amazon S3 how to retrieve from Amazon S3 :

  • file size
  • image height
  • image width ?
like image 434
Rorkkkk Avatar asked May 27 '12 09:05

Rorkkkk


People also ask

What is the size of object in S3?

Individual Amazon S3 objects can range in size from a minimum of 0 bytes to a maximum of 5 TB. The largest object that can be uploaded in a single PUT is 5 GB.

How can I get the size of an Amazon S3 bucket?

To find the size of a single S3 bucket, you can use the S3 console and select the bucket you wish to view. Under Metrics, there's a graph that shows the total number of bytes stored over time.

Is S3 good for storing 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.

What is the maximum file size of an object in an Amazon S3 bucket?

Individual Amazon S3 objects can now range in size from 1 byte all the way to 5 terabytes (TB). Now customers can store extremely large files as single objects, which greatly simplifies their storage experience.


2 Answers

You can store image dimensions in user-defined metadata when uploading your images and later read this data using REST API.

Refer to this page for more information about user-defined metadata: http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html

like image 55
Yan F. Avatar answered Sep 18 '22 13:09

Yan F.


Getting the file size is possible by reading the Content-Length response header to a simple HEAD request for your file. Maybe your client can help you with this query. More info on the S3 API docs.

Amazon S3 just provides you with storage, (almost) nothing more. Image dimensions are not accessible through the API. You have to get the whole file, and calculate its dimensions yourself. I'd advise you to store this information in the database when uploading the files to S3, if applicable.

like image 42
Pierre Avatar answered Sep 17 '22 13:09

Pierre