LA_
LA_

Reputation: 20419

How to convert bmp to jpg on GAE side?

I have a bmp image link, this image I would like to save in my datastore. So, I would prefer to convert that to jpg. How can I do it?

Upvotes: 0

Views: 472

Answers (2)

mattbornski
mattbornski

Reputation: 12553

bmp_file = 'foo.bmp'
jpg_file = 'foo.jpg'
import google.appengine.api.images
with open(bmp_file, 'rb') as bmp_fd:
    image = google.appengine.api.images.Image(bmp_file.read())
with open(jpg_file, 'wb') as jpg_fd:
    jpg_fd.write(image.execute_transforms(output_encoding=google.appengine.api.images.JPEG))

Upvotes: 0

Hauke Ingmar Schmidt
Hauke Ingmar Schmidt

Reputation: 11607

You would use the ImageService which in fact can only return JPEG, PNG and WEBP but can read BMP.

Upvotes: 5

Related Questions