python-imaging-library

How to rotate a image in Python tkinter Window

How to rotate a image in Python tkinter Window Question: I am working on a python messaging application using tkinter and i need a loading screen animation but none of them where fitting with my purpose so i Tried to rotate a image in python continusly which will look like a animation. This is the …

Total answers: 1

How can i read an image with Pyplot from memory instead of a file?

How can i read an image with Pyplot from memory instead of a file? Question: This piece of code is working, but I want to avoid the use of the temporal file, i have tried differents ways but not working. Does anyone knows how to do it? or the temp file is mandatory? from PIL …

Total answers: 2

Resize any image to 512 x 512

Resize any image to 512 x 512 Question: I am trying to train a stable diffusion model, which receives 512 x 512 images as inputs. I am downloading the bulk of images from the web, and they have multiple sizes and shapes, and so I need to preprocess them and convert to 512 x 512. …

Total answers: 1

PIL/Numpy: enlarging white areas of black/white mask image

PIL/Numpy: enlarging white areas of black/white mask image Question: I want to produce a Python algorithm which takes in a ‘mask’ RGB image comprised exclusively of black and white pixels. Basically, each mask is a black image with one or more white shapes on it (see below). I want to transform this image by enlarging …

Total answers: 1

'cannot write mode RGBA as JPEG' when saving image

'cannot write mode RGBA as JPEG' when saving image Question: I’m getting: OSError at /admin/blog/post/add/ cannot write mode RGBA as JPEG error when uploading an image file other than ‘jpeg’ with Pillow. This is the function I’m using to resize the image: def resize_image(image, size): """Resizes image""" im = Image.open(image) im.convert(‘RGB’) im.thumbnail(size) thumb_io = BytesIO() …

Total answers: 1

Django: Webp conversion fails and creates empty picture element while all debugging efforts fail

Django: Webp conversion fails and creates empty picture element while all debugging efforts fail Question: Update: After making some smaller changes to the accepted answer i was able to resolve it: class GalleryView(APIView): parser_class = (FileUploadParser,) def post(self, request): # Extract the facility ID and list of pictures from the request print(‘post method called’) facility_id …

Total answers: 1

convert PIL.Image to IOBase class

convert PIL.Image to IOBase class Question: I have a bot that creates a qr code and I want it to send qr code to the user without saving it to the hard drive I create qr code like this: import qrcode qr_code_img = qrcode.make(‘some data’) # in handler used # qrcode.make(message.text’) print(type(qr_code_img)) # <class ‘qrcode.image.pil.PilImage’> …

Total answers: 1

PIL creating a fuzzy image

PIL creating a fuzzy image Question: I’m currently working on a little project in which I’m trying to generate a random image of a set size with a set palette. Everything generates fine and dandy, but zooming in on the image shows the pixels are interpolated in a way that doesn’t look great. I would …

Total answers: 1

Trichromy photography based on PIL

Trichromy photography based on PIL Question: I’m trying to imitate in a simple way (=> without any I.A.) the old trichromy process to colorize B&W photographs. Here’s the start picture : I copied this picture in a red, green and blue version by using Pillow : Each filtered picture has a reduced opacity (I used …

Total answers: 1