10,134 questions
1
vote
1
answer
37
views
Why does this Python Pillow script not adhere to the alpha value I've specified to fade to the background colour?
I've been trying to write a script to draw some arcs which fade out to the background colour (see sample below).
from PIL import Image, ImageDraw
import math
import random
def draw_concentric_circles(...
0
votes
0
answers
117
views
PIL image.open() cannot identify image file error in python
I am running Python 3.12.10 on Visual Studio Code.
I am working on a python script that opens a PPT file, takes screenshots of each slide and stores them in a temporary directory file under "C:/...
Advice
1
vote
8
replies
96
views
Download smaller version of large image over network
Our organization has HD images that are over 20 MB in size on a network drive. When trying to preview them, is it possible to have python download a smaller version of them (to reduce bandwidth) with ...
3
votes
2
answers
82
views
Font size in Python Pillow and Microsoft Word
I want to make images in Python Pillow with text, insert the images into a Microsoft Word document, and have the font size in the image match the font size in the document. How do I make the font ...
0
votes
1
answer
90
views
NiceGUI and Image Flicking during brighness adjustment
I would like to know why image flicking while adjust it's brightness during adjustment. here is my script:
from nicegui import ui
from PIL import Image, ImageEnhance
import io, base64
original_image = ...
5
votes
1
answer
153
views
Rotating an image, how to fix "Index Error: image index out of range"?
I'm attempting to rotate an image in python by copying each individual pixel into a new blank image, (I know, probably not the best way to do it but this is what I have the theoretical knowledge basis ...
0
votes
2
answers
89
views
How does Python PIL decide if TIFF Image is RGBA or CMYK?
In C/C++, we use libtiff 4.6.0 to parsing TIFF images. We identify the type of TIFF image with:
unsigned int PhotoMetric = 0, SamplesPerPixel = 1, BitsPerSample = 1;
TIFFGetField(Tiff, ...
1
vote
1
answer
96
views
How to read a chunk of big tiff file in Python? [closed]
I have a TIFF file with a size of (48000, 432000) and I would like to upload only a piece of the image, for example, pass a parameter like (X, Y, wid, hei), where X, Y are the coordinates of the upper-...
0
votes
2
answers
100
views
Problem with offset when rotating text on an image (Pillow)
main.py
from PIL import Image, ImageDraw, ImageFont
base_img = Image.new("RGBA", (100, 100), (0, 255, 0))
txt = 'Sample <del color=red>text<del>'
rotate = 120
font = ImageFont....
0
votes
0
answers
40
views
Why does PIL Image use inverse of affine transformation matrix as argument?
Affine transformations (rotations, translations, shears and scales) can be represented (for 2-D arrays of points) as 3x3 matrices. And it is immediately clear, by looking at this matrix, what the ...
0
votes
0
answers
82
views
Coordinates satisfied conditions are outside of the expected area
I have the following code to calculate and visualise the probability of scoring 10 points or more
This is the Scoreboard image that I used to run the code
from PIL import Image, ImageDraw
import ...
0
votes
0
answers
92
views
Strange black borders on count changes with cmath on my python fractal render
I recently wrote a program which renders the mandelbrot set and encountered some irrelevent issues, which some helpful users solved for me. One user reccommended I change an aspect of my code for ...
3
votes
2
answers
131
views
The output of my fractal program is in 4 inverted quarters
I am trying to make a python program that can render the mandelbrot set. My full program can output an image of the set, but for some reason, it displays it cut up into opposite facing quarters.
This ...
-1
votes
0
answers
35
views
"Django: Cannot use ImageField because Pillow is not installed (Python 3.13, Windows) [duplicate]
PS C:\Users\ltaye\ecommerce> python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call ...
5
votes
2
answers
95
views
Pillow (PIL) affine image transform wrong direction
Using Python's Pillow (PIL) module I'm trying to shift an image 85 pixels to the right using an affine transform. The below code should to this, but instead shifts the image seemingly in the wrong ...
0
votes
1
answer
163
views
python standalone builds causes problem with pillow tkinter
I am trying to embed python standalone builds to my electron app. I downloaded standalone from https://github.com/astral-sh/python-build-standalone
Everything seems to work fine until pillow is ...
2
votes
1
answer
81
views
PIL getcolors returning None for some particular images
I am getting weird behaviour when using PIL, here is my code:
main_img = Image.open(image_url)
all_colors = main_img.getcolors(maxcolors=100000)
when I use this image:
everything works perfectly, ...
2
votes
1
answer
93
views
Getting most common colors in an image using Pillow Image.get_colors() gives wrong result
I have code which finds the top 10 colors from an image, so for that I used PIL to find all of the colors and then processed it and found the 10 most common ones, but when I try it online, results are ...
0
votes
1
answer
48
views
Replicate PIL.Image.show() scaling and normalization
I am curious what the PIL library does value scaling and normalization wise to show me crisp image and why just doing matplotlib on the extracted numpy value looks really bad.
Here is my code
...
1
vote
1
answer
78
views
Is Pillow ImageDraw.Draw.draw and Tkinter units the same?
I have a program which writes text based on the size of the image. If the size is 900x900 (tkinter units) then it will write text on 300x300, 300x600, 600x300 and 600x600, but when I try to write that,...
1
vote
1
answer
81
views
Unable to import module 'lambda_function': No module named 'PIL' even after importing pillow as a layer
I'm getting this error "Unable to import module 'lambda_function': No module named 'PIL'" when I try to run an AWS lambda that uses PIL.
What my current setup involves: I downloaded the ...
-2
votes
1
answer
69
views
Not able to load image using PIL [duplicate]
Why would the object im_test be None for the below code:
import io
import os
from PIL import Image
test_image=os.path.join("/content","drive","MyDrive","Colab ...
2
votes
1
answer
142
views
Different Pillow versions yielding different grayscale values for the same image
While converting PNG (RGB) to grayscale using two different versions of Pillow and Python, different grayscale values were observed.
I used Pillow version 5.4.1 on Python 2.7.18,
and Pillow version 11....
-1
votes
1
answer
98
views
Minimizing video export time in Moviepy
I'm trying to export videos programmatically using Moviepy. The code below generates a video from input in the form of audio and image, and adds a zoom-out effect.
I'm using this program to generate ...
0
votes
1
answer
149
views
Image Webp Import : PIL.UnidentifiedImageError: cannot identify image file [closed]
I'm trying import xlsx file into odoo (running inside a docker container) containing image url. Some of them is webp and whenever odoo try to import those webp image url, it got error :
Traceback (...
0
votes
1
answer
132
views
How to average number of frames in OpenCV2
I found this very nice example, how to make an array of frames:
https://stackoverflow.com/a/17394994/7489698
But I do not know how to use this in PIL correctly. To demonstrate it, I have sketched this ...
2
votes
1
answer
86
views
Calling ImageTk.PhotoImage() in a thread causing deadlock
I am working on a camera applicaiton where I need to get images from camera buffer and display it in a TK label live:
def display_thread_run(self):
while self.is_acquiring:
image_data = ...
1
vote
1
answer
161
views
After converting an image from 0-255 pixel range to 0-1 pixel range, the two images are different in their pixels' colors
I am making sample images using Numpy and Pillow Python libraries. I made 2 images as I describe below:
For the first image, I used np.random.randint(0, 255) to make a 3D-array to make the pixels ...
0
votes
0
answers
35
views
Importing matplotlib with conda [duplicate]
I am trying to import matplotlib. I have installed matplotlib through:
conda install matplotlib
When attempting to import matplotlib as follows:
import matplotlib
I get the following error:
import ...
0
votes
0
answers
61
views
Pillow doesn't install in venv
I am making an image converter using pillow in VS Code, but when I run pip install pillow it installs in python 3.10 folder. How to fix it?
2
votes
1
answer
171
views
PIL image by writing a matplotlib figure to BytesIO buffer not working
A function I am working on takes a dictionary with some data, plots based on the data to axes of a noninteractive matplotlib figure (so without showing it) and renders that figure to an PIL image that ...
0
votes
0
answers
69
views
Visual Studio Code not showing autocomplete package list for pillow/Pylance
having a bit of a weird issue in VS Code with Pylance/pillow, whereby the autocomplete doesn't show for PIL when anything inherits PIL.
As soon as PIL is used, can no longer get any autocompletes, ...
0
votes
1
answer
64
views
Exploring XMP tags
I am using XMP tags to perform backup of the original name of my pictures before renaming them.
I'm using this command to perform backup (works in Windows):
exiftool -P -overwrite_original_in_place &...
-1
votes
2
answers
83
views
Python CV2 and tkinter canvas
I have been working on face recognition tool and I have to draw a square on an image.
The problem is before the last line cv2.rectangle(photo1.....) because the image is not a cv2 it says I have given ...
0
votes
1
answer
220
views
How can I create a GIF image using Pillow and imageio with Python?
I have the following code that creates 60 frames using Pillow in Python 3.11.10 and that I want to use to create a GIF image (repeating endless), with a duration per frame of 0.1 seconds. The first ...
-1
votes
2
answers
79
views
Saving and Loading Images for Tensorflow Lite
Planning on using Tensorflow Lite for image classification.
To test the model, using Fashion-MNIST database to create the model following a Tensorflow basic example from their website. Created and ...
1
vote
1
answer
115
views
PIL UnidentifiedImageError: do PIL support reading .img files? and if not how to read them?
I tried to open .img images with PIL/pillow library but it seems like it does not support reading them. What can I do?
Link to sample image.
from PIL import Image
image=Image.open('C:/Users/mkmoh/...
0
votes
1
answer
116
views
How to Capture a Screenshot on macOS Using Core Graphics (CGWindowListCreateImage) with Python and PIL Without Distortion While Staying Stealthy?
I’m working on a Python script to capture screenshots on macOS in a stealthy way using Core Graphics (CGWindowListCreateImage) and PIL (Pillow). However, the screenshots I capture are heavily ...
0
votes
0
answers
41
views
PIL.UnidentifiedImageError for some image URL, but not others
I'm trying to open an image at a URL using Pillow, but it only works for some URL. In my code below, URL1 works but not URL2.
import requests
from PIL import Image
url1 = "https://picsum.photos/...
1
vote
0
answers
1k
views
Couldn't build wheel for pillow
first time coding in python and I need to add Pillow to edit some images, yet every time i try to install it I get the same error.
This is the only library in which I've had any issue.
I'm using a ...
1
vote
1
answer
65
views
Python PIL image text overlay not displayed with expected color on white background image (RGB vs RGBA mode)
Python PIL Image not working properly with overlay text image.
I am trying to use FPDF image to convert an overlayed text png image to pdf file. However, the overlay text is not in expected colour (...
0
votes
3
answers
105
views
How does a Palette work in Python Imaging Library?
Suppose I have an RGB888 image (= 8 bit per color) in which the color of each pixel evenly encodes a (raw) data byte.
Scheme:
Channel red encodes Bit 7:6
(R: 0-63 = 0b00, 64-127 = 0b01, 128-191 = 0b10,...
0
votes
1
answer
55
views
Python Image AttributeError: 'ImageDraw' object has no attribute '__array_interface__'
Getting this issue while saving and writing text over image using python image library.
I am trying to write a text over a png image using Pillow imaging library, however after trying previous answers ...
0
votes
0
answers
107
views
WebP support not enabled in Pillow 2.9.0 on CentOS 7 despite installing libwebp
I’m trying to enable WebP support in Pillow 2.9.0 on CentOS 7. I can only use yum to install packages (I cannot use pip). Here’s what I’ve done so far:
Installed libwebp and libwebp-devel using yum:
...
-1
votes
2
answers
76
views
Error when converting image to array and back to image in python, image is erased. How do I get circle back, not a straight line?
When I run this code, from original image (blue ring attached), at first show I see circle but after if I convert to RGB and do any manipulation(I tried selecting different columns, etc.), I always ...
1
vote
2
answers
101
views
Remove circular white pixels after thresholding
I would like to remove the circle surrounding the retinal blood vessels to keep only the interior.
This is the source image where I applied segmentation. I want to remove the large white circle.
...
1
vote
1
answer
132
views
Cannot determine region size; use 4-item box
I'm trying to make a QR code and I'm using pillow=11.1.0. Here's the code to generate and save the QR code:
def save(self, *args, **kwargs):
## TODO:Generate QR Code
# qr_code_url = f&...
1
vote
0
answers
124
views
Pillow Installation Windows 11
I am trying to install Pillow library but keep on getting errors. I thought it was some pip install like many others but i can't get rid of this error. Kept on searching on the internet and it turns ...
0
votes
1
answer
57
views
Why is the greyscale & B&W images created by Pillow giving a numpy.ndarray that has a 3D shape?
Input:
import numpy as np
from PIL import Image
with Image.open("testimage.png") as img:
img.convert('L') # convert to greyscale
#img.convert('1') # convert to B&W
...
0
votes
0
answers
58
views
Why is the text placement different in 1755x1241 as compared to 900x650 in Python Canvas?
I am creating a GUI application that generates certificate based on the user input.
The problem arising is that the placement of placeholder text in 900x650 canvas image does not align with the ...