How to convert or manipulate JPEGs saved as blob without image library

I have a JPEG image stored in memory as a blob, and I want to apply some basic transformations to it (e.g. resize, convert to grayscale, rotate, etc.)

I am currently using Google Scripts, which does not have its own image library, as far as I can tell.

Are there standard algorithms or similar methods that will allow me to work with a raw binary array, knowing that it represents a JPEG image, to achieve such a conversion?

+4
source share
2 answers

Not the answer you are looking for, I think, but ...

To perform image processing using JPEG files as input, you need to decode the images. Well, actually, 90/180/270 degrees rotation, turning and cropping is possible in the form of lossless operations and, thus, without decoding image data. But for something more advanced, such as resizing, you need to work with a decoded image.

Both the file structure (JIF / JFIF) and the algorithms used to compress image data in the standard JPEG format are well defined and well documented. But at the same time, the specification is rather complicated. This is certainly possible if you have the time and you know what you are doing. And if you're lucky and your JPEG drops are written the same way, you can get away from implementing only some of the specifications. But even then you will need to (re) implement large parts of the specification, and it might just not be worth it.

Using a third-party service to convert it or creating your own library using a well-known library such as libjpeg or Java ImageIO, etc., may be your best bet if you need a quick solution and don’t need too strict performance requirements.

+1
source

There are no direct image processing capabilities in Script applications. You can also open your Python as a web service and call it from Apps Script or use the REST REST API to access files from your Python application or use any api web services.

GAE Python has image processing capabilities by checking the URL below:

https://developers.google.com/appengine/docs/python/images/

Available Image Conversions

The image service can resize, rotate, flip and crop images and enhance photos. It can also combine multiple images in one image.

0
source

Source: https://habr.com/ru/post/1497019/


All Articles