png

saving an image with a transparent background

saving an image with a transparent background Question: i’ve got some issues with my program: minimap = pygame.Surface((100, 100)) background = pygame.Surface((minimap.get_width(), minimap.get_height())) background.fill((0, 0, 0)) background.set_alpha(0) minimap.blit(background, (0, 0, minimap.get_width(), minimap.get_height())) pygame.image.save(minimap, "minimap.png") the thing is, I want the background to be transparent because I display it on something else later on and i …

Total answers: 1

Loading grayscale pngs with image_dataset_from_directory returns a 3-channel tensor

Loading grayscale pngs with image_dataset_from_directory returns a 3-channel tensor Question: I have a set of grayscale png images split over 2 directories. I have used image_dataset_from_directory to load them as a Dataset object, as per documentation. When I use element_spec to inspect what has been loaded, it says the images have 3 channels: from tensorflow.keras.preprocessing …

Total answers: 1

Advanced cropping with Python Imaging Library

Advanced cropping with Python Imaging Library Question: I have an A4 png image with some text in it, it’s transparent, my question is, how can I crop the image to only have the text, I am aware of cropping in PIL, but if I set it to fixed values, it will not be able to …

Total answers: 2

How to display Images loaded with Pillow with Pygame in Python 3.7?

How to display Images loaded with Pillow with Pygame in Python 3.7? Question: I imported an image to my project using from PIL import Image myImage = Image.open(“myImageDirectory.png”) So myImage is now imported as a png file. But I want to display it to the Screen using Pygame. Normally I use import pygame win = …

Total answers: 1

How to extract exif data from a PNG photo?

How to extract exif data from a PNG photo? Question: I am on OSX, running python and trying to extra EXIF data from a large set of images in my library. I’ve been using Pillow so far with my JPG photos and it works like a charm. However, I stumbled on the first PNG photo …

Total answers: 1

How to save png copies of ppm images in Python

How to save png copies of ppm images in Python Question: I have a folder full of ppm images and I want to save png copies of them. How do I do that? I’ve tried executing the following code but nothing happens. import cv2 import numpy as np import glob import sys import os.path from …

Total answers: 3

Adjust the quality of a resized PNG image in PIL

Adjust the quality of a resized PNG image in PIL Question: No matter what I do to reduce the quality of the PNG image, this does not chnage the file size, it appears that it is not working with me, how can I use quality argument to reduce the quality and hence the file size …

Total answers: 2

OpenCV – Turn Transparent Part of PNG white

OpenCV – Turn Transparent Part of PNG white Question: I am new to OpenCV so please bear with me if my qustion seems silly to you. I have a set of images that all have a transparent border on the left and right like you can see below: I want to erase these borders so …

Total answers: 1

Show Backgroundimage in 3D Graph with plot_Surface

Show Backgroundimage in 3D Graph with plot_Surface Question: I’m looking for a way to show a .png image on the background of a 3D graph. I tried it with this Post here but even if i copy the exact code: from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm from matplotlib.ticker import LinearLocator, FormatStrFormatter import matplotlib.pyplot …

Total answers: 1

Importing PNG files into Numpy?

Importing PNG files into Numpy? Question: I have about 200 grayscale PNG images stored within a directory like this. 1.png 2.png 3.png … … 200.png I want to import all the PNG images as NumPy arrays. How can I do this? Asked By: pbu || Source Answers: Using just scipy, glob and having PIL installed …

Total answers: 9