Simple image manipulation using Python

What am I trying to do:

I want to give the user the ability to upload a picture of any size. Then this image changes if it exceeds 1024 or above 768. Then it resizes the image within these boundaries, but retains the proportions. Then it adds a translucent watermark to the lower right corner and saves the file.

Before he adds the watermark, he will create a copy of the image and resize it to the size of the thumbnail (also keeping the proportions) and save it in a separate folder.

Problems with PIL:

Regarding resizing, I was hoping he would have a way to do smart resizing (keep proportions). In addition, I did not have much control over the quality level while saving it as a JPEG. I had to save it as PNG in order to maintain full quality, which was pretty heavy.

For a thumbnail, it seems like it can be quite difficult to read the PIL documentation, but I could be wrong.

Question

Are there any other, more advanced image libraries for Python that might be a little more relevant or include some of the features I'm looking for? Are there any public functions that perform what I'm looking for that I could use? I do not mind writing this material myself, but I want to check first. Thank!

+3
3

, ( ).

, , , Python, , .

, , , , JPEG.

handbook:

:

1 () 95 ( ). 75. 95; 100 JPEG .

? , ?

+4

. , , / API, . , .resize(factor = 0.8, keepRatio = True), .resize(hFactor = 0.8, vFactor = 0.8).

, imageMagick PythonMagick: http://www.imagemagick.org/script/index.php

( ) , , , .

, PIL , , , , , magick ++, Python, . PIL, , .

+1

As a last resort, convert the image to a numpy array, change it as you like, and put it back.

0
source

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


All Articles