python-imaging-library

How do you download an image and extract Exif data using Python PIL?

核能气质少年 提交于 2020-04-30 07:35:56
问题 I am trying to read the Exif data from a downloaded image. I save the image to my computer in one function then try to read the data in another function, but I keep getting a bad mode error. I have been able to read the data from a pre saved image and just used ._getexif() but when I try to do the same thing with the image I download it does not work. What am I doing wrong? Here is the loop that calls the two functions. else: imgTags = findImages(url) for imgTag in imgTags: imgFileName =

How do you download an image and extract Exif data using Python PIL?

て烟熏妆下的殇ゞ 提交于 2020-04-30 07:35:27
问题 I am trying to read the Exif data from a downloaded image. I save the image to my computer in one function then try to read the data in another function, but I keep getting a bad mode error. I have been able to read the data from a pre saved image and just used ._getexif() but when I try to do the same thing with the image I download it does not work. What am I doing wrong? Here is the loop that calls the two functions. else: imgTags = findImages(url) for imgTag in imgTags: imgFileName =

Error decode byte when send image in discord

拜拜、爱过 提交于 2020-04-17 21:41:26
问题 I have some problems with sending images in discord. I decide to use Pillow library for creating images and I want to send image which is created by this library without save . I found out what I can convert Image object to binary data and put in fp argument. But it raised encoding error. Code: image = Image.open("test.png") image_binary = BytesIO() image.save(image_binary, "PNG") image_binary = image_binary.getvalue() await ctx.send(file=discord.File(fp=image_binary)) Error: Traceback (most

Pixel colour intensity

狂风中的少年 提交于 2020-04-17 21:25:56
问题 This collage is what im supposed to get.... import PIL from PIL import Image from PIL import ImageEnhance from PIL import ImageDraw # read image and convert to RGB image=Image.open("readonly/msi_recruitment.gif") image=image.convert('RGB') # build a list of 9 images which have different brightnesses enhancer=ImageEnhance.Brightness(image) images=[] for i in range(1, 10): images.append(enhancer.enhance(i/10)) # create a contact sheet from different brightnesses first_image=images[0] contact

How to capture mouse movement for the whole window in opencv python?

心不动则不痛 提交于 2020-04-16 08:33:08
问题 I know and have seen tons of documentations explaining about how to capture mouse movement within a given window using mouseclick events in opencv. What I want to know is that if is there a way to capture mouse movements (x,y co-ordinates) for the entire screen of my system. Any link, documentation or code snippet will be really helpful to proceed me with the same. 回答1: Depending on your OS, you can do that with pyautogui like this: #!/usr/bin/env python3 import time import pyautogui for i in

Change image color in PIL module

試著忘記壹切 提交于 2020-04-16 05:48:33
问题 I am trying to vary the intensity of colors to obtain a different colored image... import PIL from PIL import Image from PIL import ImageEnhance from PIL import ImageDraw # read image and convert to RGB image=Image.open("readonly/msi_recruitment.gif") image=image.convert('RGB') # build a list of 9 images which have different brightnesses enhancer=ImageEnhance.Brightness(image) images=[] for i in range(1, 10): images.append(enhancer.enhance(i/10)) # create a contact sheet from different

how to give dynamic value for area selection in imagegrab library in python

☆樱花仙子☆ 提交于 2020-04-16 01:56:26
问题 Using this script i am trying to take a screenshot of my desktop of a particular area.(using Tkinter gui) But with this code i can only take screenshot of the fix area (frame) of desktop. So what i want to do is try to set the value of (bbox of imagegrab) dynamic. And by dynamic i mean it should only capture the screen area which is selected(highlighted) by my mouse cursor any where on screen and can be of any size. import tkinter as tk from tkinter import * from PIL import Image, ImageGrab

Identify the color values of an image with a color palette using PIL/Pillow

你说的曾经没有我的故事 提交于 2020-03-23 12:02:32
问题 I'm trying to identify the colors of the used color palette of an image with PIL/pillow. I've tried the following: image[x,y] : this will only give me the index number of the corresponding pixel (i.e. 1 ) image.getpixel((x,y)) : again, this will only give me the index number of the corresponding pixel (i.e. 1 ) image.getcolors() : This will give me the number of pixels and their corresponding index number (i.e. [(2, 1), (2, 0)] ) image.palette : Returns a "PIL.ImagePalette.ImagePalette object

Identify the color values of an image with a color palette using PIL/Pillow

醉酒当歌 提交于 2020-03-23 12:02:24
问题 I'm trying to identify the colors of the used color palette of an image with PIL/pillow. I've tried the following: image[x,y] : this will only give me the index number of the corresponding pixel (i.e. 1 ) image.getpixel((x,y)) : again, this will only give me the index number of the corresponding pixel (i.e. 1 ) image.getcolors() : This will give me the number of pixels and their corresponding index number (i.e. [(2, 1), (2, 0)] ) image.palette : Returns a "PIL.ImagePalette.ImagePalette object

Python Tkinter Treeview add an image as a column value

我是研究僧i 提交于 2020-03-20 20:45:21
问题 i'm trying to add an Image to the first column of every row on a treeview, but no matter what I do, always end up with the name of the object "pyimage1" showed instead of the actual image. As this image shows The code that i'm using is something like this. from tkinter import PhotoImage. self._img = PhotoImage(file="resources\information_picto.gif") self.tree.insert('', 'end', values= self._image,self.name, self.status, self.cores, self.turn, self.added_time) I've tried with png, with the