python-imaging-library

Opencv Error while sending png images through pytesseract

Opencv Error while sending png images through pytesseract Question: I am using pytesseract for ocr and it works fine for jpg,jpeg and some png files but crashes on selected png files which are mobile screenshots Here is my code: img = cv2.imread(‘test.png’,cv2.COLOR_BGR2GRAY) custom_config = r’–oem 3 –psm 6′ data=pytesseract.image_to_string(img, config=custom_config) print(data) The error generated is: …

Total answers: 1

Pillow conversion from RGB to indexed P mode

Pillow conversion from RGB to indexed P mode Question: I have an RGB image with only 25 colors, and I want to convert it to P mode to make it indexed (saving space, as far as I understand), but the resulting image, though in P mode and indexed, has got 70 colors instead of 25: …

Total answers: 2

Struggling when converting PNG to ICO file?

Struggling when converting PNG to ICO file? Question: Hi guys please help me i can’t solve this, i have this image When i try to convert it to ico using from PIL import Image,ImageTk png = Image.open("converter.png") png.save("icon.ico", format=’ICO’,quality=100) And i use the icon for a shortcut in the desktop the result is this It’s …

Total answers: 2

Pillow raises error: "AttributeError: read" when attempting to use Image.Open for ImageTk

Pillow raises error: "AttributeError: read" when attempting to use Image.Open for ImageTk Question: I am attempting to create a paint program but in my open() function, it raises this error: Exception in Tkinter callback Traceback (most recent call last): File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0libtkinter__init__.py", line 1921, in __call__ return self.func(*args) File "C:Users——-PycharmProjectsPaintmain.py", line 31, in open canvas.create_image(0, …

Total answers: 1

Detect almost grayscale image with Python

Detect almost grayscale image with Python Question: Inspired by this question and this answer (which isn’t very solid) I realized that I often find myself converting to grayscale a color image that is almost grayscale (usually a color scan from a grayscale original). So I wrote a function meant to measure a kind of distance …

Total answers: 2

Replacing ones and zeros in a 2D numpy array with another array?

Replacing ones and zeros in a 2D numpy array with another array? Question: I have a simple problem that I am trying to solve using numpy in an efficient manner. The jist of it is that I have a simple 2D array containing ones and zeros representing an image mask. What I want to do …

Total answers: 3

Changing background color for part of image in Open CV

Changing background color for part of image in Open CV Question: I am able to extract data from image where it is having white background, data with black background I am not able to extract. How to get this data. Below is the code I tried but not working.. #denoise #For normal image #img = …

Total answers: 1

Python PIL Rotate (Image Result Quality)

Python PIL Rotate (Image Result Quality) Question: I’m using Python 3.11 with Pillow 9.3.0 and OpenCV 4.6.0.66. I want to make sure if I doing 90 degree rotate with PIL, the quality of image is same. ret = False frame = None camera = cv2.VideoCapture(0, cv2.CAP_DSHOW) if camera.isOpened(): camera.set(cv2.CAP_PROP_FPS, 30.0) camera.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc(‘m’, ‘j’, ‘p’, ‘g’)) …

Total answers: 1

How to load fonts from GCS(problem solved)

How to load fonts from GCS Question: I want to load "fonts" from Google Storage, I’ve try two ways, but none of them work. Any pointers? Appreciated for any advices provided. First: I follow the instruction load_font_from_gcs(uri)given in the answer here, but I received an NameError: name ‘load_font_from_gcs’ is not defined message. I installed google …

Total answers: 1