0

I have some images (jpg, png) uploaded to aws s3 bucket. I want to extract some informations (lambda is written in golang) from the image (width and height). Is it possible to do this without downloading the image?

cupakob
  • 7,691
  • 24
  • 60
  • 75
  • 2
    No. S3 is just a blob store. The only information it knows about the blobs are simple metadata like key, size, creation date, and so forth. You could tag them with their dimensions when you upload them if dimensions are known at that time, then you could read the tags to get the dimensions back out, but that's about it. – Adrian Oct 10 '18 at 14:46

2 Answers2

3

You can do a partial download of the object using the range header See this SO answer S3: How to do a partial read / seek without downloading the complete file?

in the AWS go sdk func (Downloader) DownloadWithContext seems like it should provide range feature

Once you have the partial file it may be possible to extract the size information, see this answer What is the header size of png, jpg/jpeg, bmp, gif and other common graphics format?

Vorsprung
  • 28,957
  • 4
  • 32
  • 55
0

S3 will not calculate dimensions for you. You calculate them beforehand.

You can use user-defined meta tags. You can set them when you send the object, or update them after they exist.

For private objects, the API must return user-defined meta tags.

For public objects, you can use the traditional GET verb or just the http HEAD verb in the object's public url.

Even javascript + ajax can read this header information.

William
  • 106
  • 4