10,126
questions
0
votes
0
answers
27
views
OSError When Saving Barcode in Roaming Folder After Converting Python Script to Executable on Windows
I'm having trouble saving a barcode image to the Roaming folder when I convert my Python script to an executable using PyInstaller on Windows. The script works fine during development, but after ...
0
votes
0
answers
31
views
auto generating thumbnails from images with pillow and bytesIO i django
I've been trying to automatically generate thumbnails from images that I upload to the admin console in Django (I'm using drf). I want to be able to generate thumbnails for images that I upload when ...
0
votes
0
answers
31
views
Incorrect bounding box with PIL text rendering
I am trying to render a custom font using PIL since tkinter doesn't support custom fonts. My approach is to load in the font, and then draw it on an image, and then size the image to be the same size ...
1
vote
1
answer
41
views
Creating a grid of n tiles so that the grid is approximately square
I have a variable amount of image tiles of specific dimensions that need to be fit into a grid. What is the best method of creating a grid that approximates a square the best?
For example, if the ...
0
votes
0
answers
39
views
Python - PIL.save() issue - The fill character must be a unicode character, not bytes
I have some interesting issue with saving Image via PIL library.
Aim:
to change metadata like "Date Taken", "Creation Date" to pictures from picture name (name is standardize by ...
0
votes
0
answers
10
views
ImageTk module fails
I'm trying to use the pillow package for Python in my Visual Studio Code IDE
But it seems like the ImageTk module is not working properly.
Every time I run the script it tells me that there is an ...
0
votes
0
answers
23
views
After rotating the image, a black background appears instead of a transparent background, which prevents these images from being overlaid normally
I wrote a Python program with Pillow to overlay a bunch of small images onto one large one. There was an adequate overlay, in which the transparent color did not replace the previous superimposed ...
1
vote
0
answers
126
views
ModuleNotFoundError: No module named 'PIL' while I installed this package
Traceback(most recent call last):
File "c:\Users\AlarmTran\nifti2dicom-main\nifti2dicom-main\main.py", line 11, in <module>
import PIL
ModuleNotFoundError: No module named 'PIL'
...
0
votes
1
answer
44
views
Python: Using Pillow to convert any format to png, any way to speed the process up?
I'm currently working on an application that decompiles a PDF file into raw text, images, tables, etc...
but I've encountered the problem where a lot of PDFs use a lot of different image formats, so I ...
-1
votes
0
answers
268
views
Failed to build pillow pymunk ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects
I tried to download arcade, but for some reason it gives such an error, what can I do to fix it?
Failed to build pillow pymunk
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml ...
0
votes
0
answers
22
views
Obtuse issues with bitmap derived screenshots
I have these functions in my program, which are supposed to take a screenshot of a specific application by copying its bitmap data and then crop that down to specific coordinates. Last night I was ...
0
votes
0
answers
20
views
Why is my pywin32gui/PIL function not returning an image generated from a bitmap like I expect, but rather a completely black image?
I have this function in my code, which is supposed to generate a bitmap from an application and convert that to an image using Pillow. Whenever I save the output, though, it only returns a black image....
0
votes
0
answers
23
views
How to Measure text width [duplicate]
I need to get the text width to precisely count each text word start point. I am creating some text animations with video background by ffmpeg library. To get animations with good quality I need to ...
0
votes
1
answer
92
views
Convert Image under UV Light to RGB?
I have an Image (banknotes) as a dataset that is under UV Light. I want to image process it back to RGB again in order to detect which banknote is it (if it is 20, 50, 100 and so on bill)
Since this ...
0
votes
1
answer
70
views
Why image retrieval from SQLite database is failing
I am saving an image in the SQLite database with the code below:
import sqlite3
import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox
from PIL import Image, ImageTk
...
2
votes
2
answers
59
views
Make image from uint8 RGB pixel data
I am trying to make a library related to RGB pixel data, but cannot seem to save the image data correctly.
That is my output image.
This is my code:
pixelmanager.py
from PIL import Image
import numpy ...
0
votes
0
answers
24
views
Django based website having error with Pillow after deployment to Heroku Server while I want to migrate. (DB = Postgresql)
I have deployed my website based on django to Heroku, and changed my database from sqlite3 to postgresql, and when i want to migrate having an error with Pillow. Asking to install Pillow for working ...
0
votes
0
answers
25
views
Dependency in library is outdated, but when you change it it cannot redirect the new name of the dependency to the library
I want to use from torchvision import transforms but there's an error that says like this
{
"name": "ImportError",
"message": "cannot import name 'Image' ...
0
votes
0
answers
30
views
How can I alter truncated images so that they won't trigger a "cannot identify image file" error withPIL?
For some PNG images (all have sizes 50KB and below), this script fails:
img = Image.open('path_to_img')
img
with the error
UnidentifiedImageError: cannot identify image file
I have looked up similar ...
0
votes
1
answer
37
views
arr_to_image changes the grayscale images
When processing images, I encountered strange behavior when converting a PIL gray image to a NumPy array.
Here is a small code that loads a gray image image.
from keras.utils import img_to_array, ...
0
votes
1
answer
33
views
Create image fitted to text in python
Is there a canonical way in python to create a new image that fits exactly a given text in python? With pillow or something similar?
Like I would for example do with ImageMagick:
convert -font Calibri ...
0
votes
1
answer
42
views
Can't install Python Imaging Library "Pillow"
I have tried to install pillow library for my Django project it won't install. I have tried many times there are no specific answer for problem on internet.
First Try
Terminal Input:
(venv) PS C:\...
2
votes
1
answer
58
views
How to pass tkimage raw data to cv2 functions?
TLDR
I am writing a video recorder with tkinter and cv2. How to pass tkimage raw data to cv2.VideoWriter, cv2.circle, and so on?
Current approach
I using a numpy array (self.data) as a middle man. But ...
0
votes
1
answer
61
views
how to use variables inside a u string
I'm writing a code that takes an Arabic text that contains dialects (You can think of it as special characters such as ö, å and ä) and writes it on an image. The way I found to display those dialects ...
0
votes
1
answer
86
views
Import Pillow on Python 3.12.4 virtual environment on Ubuntu 24.04
I am running Python 3.12.4 in a virtual environment under Ubuntu 24.04. Pillow 10.4.0 installed without warnings using the command: python -m pip install pillow.
However a script:
from PIL import ...
-2
votes
1
answer
84
views
Need to resample or resize images in python
I have two images, want to resize these images as should be same imagedata(circles/text) with exact same pixel location of both images. The distance between objects should also be same of both images....
0
votes
1
answer
63
views
Django- how to convert <class 'django.core.files.uploadedfile.InMemoryUploadedFile'> to an image?
I have a form that uploads an image to my view; the uploaded image type is:
<class 'django.core.files.uploadedfile.InMemoryUploadedFile'>
I want to process the image though; thus I need it in ...
1
vote
1
answer
39
views
How to adjust and center font text based on available space
I am currently writing a program that prints certificates when a course is completed. The certificates are in .png format and I am using Pandas to read the name of the person from an Excel spreadsheet ...
0
votes
1
answer
27
views
How do I show this thumbnail on Pillow?
I am learning to use Pillow. I am trying to display the thumbnail but don't know how.
Here is my current code:
img = Image.open('block.jpg')
new = img.thumbnail((400,400),Image.Resampling.LANCZOS)
I'...
1
vote
1
answer
55
views
Why does the picture change to a white area?
I had again a problem while coding my video editor... Here is a simplified code (the variables are in German language, don't wonder and feel free to ask if you don't understand something):
from ...
0
votes
1
answer
53
views
AttributeError: property 'mode' of 'JpegImageFile' object has no setter
I'm getting an error:
AttributeError: property 'mode' of 'JpegImageFile' object has no setter
While trying to open an image using the Pillow library.
My code:
from pil import Image as pl
my_img = pl....
0
votes
0
answers
29
views
I use the win32print library to print on a thermal printer. I want to print images, but it does not print and does not give me any errors
from escpos import printer
import tkinter as tk
import win32print
from PIL import Image, ImageWin,ImageOps
hPrinter = win32print.OpenPrinter("XP-80")
current_job = win32print....
0
votes
1
answer
64
views
Generating text images
I am generating images containing a specific text. There is no problem generating an image with text where all text tokens are from one font. I wanted to bold out some words randomly, which requires ...
1
vote
1
answer
64
views
PIL Image in a ipywidgets Container widget
I have some PIL images coming from some library and am trying to understand what is going on with them. To do that, I compute some values, call the library, and look for the picture. The computed ...
0
votes
0
answers
35
views
Does Image.fromarray works only with numpy.array objects?
That's a simple question, but I'm using numpy for the first time so I'm quite confused.
I think I understand the how should it works: my function named img_PILarray below creates an array object ...
0
votes
1
answer
39
views
How can you capture a screenshot of any window using Python on Wayland?
For context I have a PyQt5 widget with a single button that let's me select a region of the screen to capture. I can use pillow and mss to capture stuff on X11 like so
def take_screenshot(self, x1, y1,...
0
votes
1
answer
30
views
TKinter places a strange white box on a displayed image
I am developing a GUI using TKinter that allows users to interactively set parameters that are used for processing some images. The GUI displays the image that is being analyzed so that users can see ...
0
votes
0
answers
39
views
Emojis not rendering with colors
I am trying to add COLOR emojis onto images as overlay, but it seems like the emojis keep being rendered in black and white, and also transparent:
This is what I'm currently working with:
def ...
0
votes
1
answer
48
views
Error loading .jpg images in tkinter window using tk.PhotoImage
Question:
I am working on a tkinter application where I need to display images in the GUI. While loading .png images works perfectly fine, I am encountering difficulties when attempting to load .jpg ...
0
votes
1
answer
32
views
Image to radar values
I am trying to do similarly to the topic responded to in:RADAR image for dBZ values
However, here I have a figure with different dimensions and a color palette that is not so simple.
Legend:
image:
...
0
votes
0
answers
30
views
When saving WebP using PIL in Python, the last pixel (bottom-right) becomes black
Problem: When saving a sequence of images as a lossless WebP animation using PIL, the last pixel (bottom-right) becomes black.
from PIL import Image
for png_file in png_files:
image = Image.open(...
0
votes
1
answer
33
views
When calling torchvision.transforms.Normalize and converting to PIL.Image, how are values above 1 handled?
Applying torchvision.Normalize should lead to values below 0 and above 1, and thus below 0 and 255 when switching to integer values.
However, when watching the values, this seems NOT to be the case. ...
1
vote
1
answer
24
views
Why Image Pasting not working in Python using Image Module
from PIL import Image, ImageOps
import sys
list = ['jpg', 'jpeg', 'png']
before = sys.argv[1]
after = sys.argv[2]
if len(sys.argv) == 3:
if before[-3:] in list and after[-3:] in list and after[...
2
votes
1
answer
96
views
How to fit an image exactly inside an Excel cell using Python and XlsxWriter?
I'm working on a Python script that inserts images into Excel cells using the XlsxWriter library. My goal is to have each image fit precisely within its cell, without any overflow or unused space.
...
0
votes
1
answer
74
views
Reshape array to RGB array with missing values
I'm creating a tkinter user interface to display several images which a user will manipulate (translate and rotate) over each other. As the user is manipulating the images I need to calculate the new ...
0
votes
1
answer
82
views
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\User\\Downloads.png' in Python
Everything was going smoothly until I tried to use PIL, I have been stuck on this for a few days, so if you can help, it will be very good.
import PIL
from PIL import Image
fp = Image.open(r"C:\...
0
votes
1
answer
56
views
Drawing a circle around a png image using PIL
I am trying to put player headshots inside / mask a circle around.
However, I get a colour on the background rather than transparent. Does anyone have any idea how I might achieve this? PS. I don't ...
1
vote
2
answers
104
views
Save 16-bit PGM Image with Python PIL?
I am attempting to convert an image in PNG format to a 16-bit PGM format and save it using Python's PIL library. I'm using Python 3.12.4 in all examples shown.
Using the following test.png image:
...
0
votes
0
answers
54
views
How do I convert a big Tkinter window to a picture?
I am creating a dashboard, and I want to copy the window I created onto a PowerPoint presentation.
My problem with using Pillow or other modules is that they take only what's on the screen; however, ...
1
vote
1
answer
31
views
How to change rgb values using numpy where function in python
from PIL import Image
import numpy as np
target_file = r'D:\rgb_test\C\test.tga'
img = Image.open(target_file)
basePixel = np.array(img)
old_rgb_value = (255, 0, 0)
new_rgb_value = (57, 57, 57)
I ...