pillow

Error while converting webp image file to jpg in python

Error while converting webp image file to jpg in python Question: I have written small program to convert webp to jpg in python import imghdr from PIL import Image im = Image.open(“unnamed.webp”).convert(“RGB”) im.save(“test.jpg”,”jpeg”) when executing it gives me following error No handlers could be found for logger “PIL.ImageFile” Traceback (most recent call last): File “webptopng.py”, …

Total answers: 4

Error installing Pillow on ubuntu 14.04

Error installing Pillow on ubuntu 14.04 Question: I’m trying to install Pillow on Ubuntu 14.04 using this command: pip install Pillow but the installation fails with this error: ValueError: –enable-jpeg requested but jpeg not found, aborting. Asked By: Navid777 || Source Answers: The problem was that the package libjpeg-dev was not installed. To solve the …

Total answers: 5

Open PIL image from byte file

Open PIL image from byte file Question: I have this image with size 128 x 128 pixels and RGBA stored as byte values in my memory. But from PIL import Image image_data = … # byte values of the image image = Image.frombytes(‘RGBA’, (128,128), image_data) image.show() throws the exception ValueError: not enough image data Why? …

Total answers: 2

How do I close an image opened in Pillow?

How do I close an image opened in Pillow? Question: I have a python file with the Pillow library imported. I can open an image with Image.open(test.png) But how do I close that image? I’m not using Pillow to edit the image, just to show the image and allow the user to choose to save …

Total answers: 2

"ValueError: bad transparency mask" when pasting one image onto another with Python Imaging Library?

"ValueError: bad transparency mask" when pasting one image onto another with Python Imaging Library? Question: I’m trying to paste an image onto a backgorund with Python Imaging Library like this: card = Image.new(“RGB”, (220, 220), (255, 255, 255)) img = Image.open(“/Users/paulvorobyev/test.png”) … x, y = img.size card.paste(img, (0, 0, x, y), img) card.save(“test.png”) When I …

Total answers: 1

How to install Pisa on Ubuntu

How to install Pisa on Ubuntu Question: How can i install Pisa on Ubuntu? http://xhtml2pdf.appspot.com/static/pisa-en.html What is the best way to install it ? Asked By: Renato Prado || Source Answers: Ensure that you have pip, if you dont: What is the official "preferred" way to install pip and virtualenv systemwide? First you will need …

Total answers: 2

Decoding base64 from POST to use in PIL

Decoding base64 from POST to use in PIL Question: I’m making a simple API in Flask that accepts an image encoded in base64, then decodes it for further processing using Pillow. I’ve looked at some examples (1, 2, 3), and I think I get the gist of the process, but I keep getting an error …

Total answers: 3

PIL's ImageGrab is capturing at the wrong resolution

PIL's ImageGrab is capturing at the wrong resolution Question: I’m trying to get a full screen (1920 x 1080) capture using this code. The saved images are only 1536 x 864 though. solution: As Mark pointed out below, Windows has scaling which can be changed via Control Panel > Display (turn it all the way …

Total answers: 3

Python / Pillow: How to scale an image

Python / Pillow: How to scale an image Question: Suppose I have an image which is 2322px x 4128px. How do I scale it so that both the width and height are both less than 1028px? I won’t be able to use Image.resize since that requires me to give both the new width and height. …

Total answers: 2

Python3 Pillow Get all pixels on a line

Python3 Pillow Get all pixels on a line Question: I need to get the pixel values along a line, I’m using Python3 and Pillow. In opencv there is such a thing as a LineIterator which will return all of the appropriate pixels between two points, but I haven’t found anything like that in Pillow’s docs. …

Total answers: 4