python-imaging-library

Python3 tkinter set image size

巧了我就是萌 提交于 2020-08-27 22:18:25
问题 I have looked everywhere to find a way to set the size of an image. The image is set to a url. I have found other questions on the site but none of them have worked. import urllib.request, base64 u = urllib.request.urlopen(currentWeatherIconURL) raw_data = u.read() u.close() b64_data = base64.encodestring(raw_data) image = PhotoImage(data=b64_data) label = Label(image=image, bg="White") label.pack() That is the code that creates the image, how would I set the size of the image 回答1: As

Python Tkinter PIL generate random 200x200 image

核能气质少年 提交于 2020-08-26 10:31:33
问题 In Python Tkinter this code: # custom indicator images im_open = Image.new('RGBA', (15, 15), '#00000000') im_empty = Image.new('RGBA', (15, 15), '#00000000') draw = ImageDraw.Draw(im_open) draw.polygon([(0, 4), (14, 4), (7, 11)], fill='yellow', outline='black') im_close= im_open.rotate(90) Generates a triangle in a format I can use: In Python tkinter this code draws on a canvas I can't use: COLORS = ['snow', 'ghost white', 'white smoke', 'gainsboro', 'floral white', 'old lace' ...] for x in

PIL Issue, OSError: cannot open resource

爱⌒轻易说出口 提交于 2020-08-22 04:22:10
问题 I'm attempting to write a program that places text onto an image, I'm trying to get my head round PIL and have run into the error: OSError: cannot open resource. This is my first python program so apologies if the error is obvious. from PIL import Image from PIL import ImageDraw from PIL import ImageFont im = Image.open("example.jpg") font_type = ImageFont.truetype("Arial.ttf", 18) draw = ImageDraw.Draw(im) draw.text(xy=(50, 50), text= "Text One", fill =(255,69,0), font = font_type) im.show()

How can I feather an image horizontally using Python?

我的梦境 提交于 2020-08-10 19:25:21
问题 I need to feather an image horizontally (and not vertically), using Python. I have used Feathered edges on image with Pillow as a starting point and got to the below, which removes the additional white at the top and bottom of the image, but does not prevent the feathering at the top and bottom. How should I modify the script further to avoid the top and bottom of the image being blurred? from PIL import Image from PIL import ImageDraw from PIL import ImageFilter RADIUS = 25 INPUT_IMAGE

How can I feather an image horizontally using Python?

喜夏-厌秋 提交于 2020-08-10 19:24:06
问题 I need to feather an image horizontally (and not vertically), using Python. I have used Feathered edges on image with Pillow as a starting point and got to the below, which removes the additional white at the top and bottom of the image, but does not prevent the feathering at the top and bottom. How should I modify the script further to avoid the top and bottom of the image being blurred? from PIL import Image from PIL import ImageDraw from PIL import ImageFilter RADIUS = 25 INPUT_IMAGE

Overwrite the pixels closest to blue with (0,0,255) blue

一笑奈何 提交于 2020-08-10 19:19:47
问题 I'm using Python and PIL (or Pillow) and want to run code on files that contain two pixels of a given intensity and RGB code (0,0,255). The pixels may also be close to (0,0,255) but slightly adjusted ie (0,1,255). I'd like to overwrite the two pixels closest to (0,0,255) with (0,0,255). Is this possible? If so, how? Here's an example image , here zoomed with the pixels I want to make "more blue" here The attempt at code I'm looking at comes from here: # import the necessary packages import