pillow

Feathered edges on image with Pillow

谁说我不能喝 提交于 2019-12-22 09:40:34
问题 I'm trying to figure out how to feather the edges of an image using Pillow with Python. I need something like this cute cat (ignore the visible edges): I tried im.filter(ImageFilter.BLUR) but is not what I'm looking for. 回答1: Have a look at this example: from PIL import Image from PIL import ImageFilter RADIUS = 10 # Open an image im = Image.open(INPUT_IMAGE_FILENAME) # Paste image on white background diam = 2*RADIUS back = Image.new('RGB', (im.size[0]+diam, im.size[1]+diam), (255,255,255))

Pillow and JPEG2000: decoder jpeg2k not available

ⅰ亾dé卋堺 提交于 2019-12-22 09:39:09
问题 I'm trying to set up Flask-IIIF to work with jp2 -files, or JPEG2000. Right out of the box I get an error from the Pillow library: IOError: decoder jpeg2k not available I've tried googling it, and one StackOverflow post told me to make sure libjpeg-dev and libjpeg8-dev are installed and up to date, but they were already installed. After making sure they were there, I did try to reinstall pillow without cache: pip install --no-cache-dir -I pillow The environment is Docker, based on a 15.10

saving an image to bytes and uploading to boto3 returning content-MD5 mismatch

怎甘沉沦 提交于 2019-12-22 01:46:02
问题 I'm trying to pull an image from s3, quantize it/manipulate it, and then store it back into s3 without saving anything to disk (entirely in-memory). I was able to do it once, but upon returning to the code and trying it again it did not work. The code is as follows: import boto3 import io from PIL import Image client = boto3.client('s3',aws_access_key_id='', aws_secret_access_key='') cur_image = client.get_object(Bucket='mybucket',Key='2016-03-19 19.15.40.jpg')['Body'].read() loaded_image =

How to convert this indexed PNG to grayscale and keep transparency, using Python and Pillow?

风格不统一 提交于 2019-12-21 22:47:21
问题 I am trying to convert images to grayscale using Python/Pillow. I had no difficulty in most images, but then, while testing with different images, I found this logo from the BeeWare project, that I know that has been further edited with some image editor and recompressed using ImageOptim. The image has some kind of transparency (in the whole white area around the bee), but black color gets messed up. Here is the code: #/usr/bin/env python3 import os from PIL import Image, ImageFile src_path =

ImportError: cannot import name '_imagingtk'

浪子不回头ぞ 提交于 2019-12-20 03:03:31
问题 I am using Anaconda with python 3.4 and I am not able to get all the pillow packages I need I am afraid on Windows 8.1. I installed pillow via the Anaconda console with: pip install pillow which lead to: The following packages will be UPDATED: conda: 3.10.0-py34_0 --> 3.10.1-py34_0 conda-env: 2.1.3-py34_0 --> 2.1.4-py34_0 pillow: 2.7.0-py34_0 --> 2.8.1-py34_0 pip: 6.0.8-py34_0 --> 6.1.1-py34_0 setuptools: 14.3-py34_0 --> 15.0-py34_0 Now, in the spyder IPython console I start with: import

JPEG Lossless in DICOM

浪尽此生 提交于 2019-12-20 02:56:36
问题 In the DICOM spec one of the Transfer Syntaxes is 1.2.840.10008.1.2.4.70 defined as JPEG Lossless, Nonhierarchical, First- Order Prediction (Processes 14 [Selection Value 1]) . What does "JPEG Lossless, Nonhierarchical, First- Order Prediction (Processes 14 [Selection Value 1])" mean? Is this format the same as JPEG-LS? This page seems to indicate that there is some difference (JPEG-LS is listed in the bottom section). Is is possible to read or write this format in Python? Looking over the

Encode Base64 Django ImageField Stream

拟墨画扇 提交于 2019-12-19 19:52:31
问题 I receive an Image through my form, which I not want to save as usual in a FileField but in a CharField as Base64. This is my current setup: models.py class Image(models.Model): company = models.ForeignKey(Company) img = models.TextField() img_id = models.CharField(blank=True, null=True, max_length=64) img_class = models.CharField(blank=True, null=True, max_length=64) created = models.DateField(auto_now_add=True, editable=False) forms.py class ImageForm(forms.Form): img = forms.ImageField()

python - pyinstaller “RuntimeWarning: Parent module 'PyInstaller.hooks.hook-PIL' not found while handling absolute import” and “tcl” related errors

痴心易碎 提交于 2019-12-19 11:49:11
问题 I get a warning message while trying to create exectable file using pyinstaller . This warning appeared after installing Pillow . Previously i nevre got any warnings and was able to make it through. the warning i get by pyinstaller is: 7314 INFO: Analyzing main.py /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/hooks/hook-PIL.Image.py:14: RuntimeWarning: Parent module 'PyInstaller.hooks.hook-PIL' not found while

How to create a circular thumbnail using python pillow and overlap on background image

最后都变了- 提交于 2019-12-19 02:49:13
问题 avatar.jpg back.jpg How to synthesize two images as follows? I Effect: 回答1: Here's an example using your images. Dimensions are hardcoded in the example, but you can easily replace them with calculations. avatar.jpg and background.jpg are images in your post saved as is. Here's a link to github repo for this example : python_pillow_circular_thumbnail from PIL import Image, ImageOps, ImageDraw im = Image.open('avatar.jpg') im = im.resize((120, 120)); bigsize = (im.size[0] * 3, im.size[1] * 3)

Python — change the RGB values of the image and save as a image

雨燕双飞 提交于 2019-12-18 09:24:02
问题 I can read every pixel' RGB of the image already, but I don't know how to change the values of RGB to a half and save as a image.Thank you in advance. from PIL import * def half_pixel(jpg): im=Image.open(jpg) img=im.load() print(im.size) [xs,ys]=im.size #width*height # Examine every pixel in im for x in range(0,xs): for y in range(0,ys): #get the RGB color of the pixel [r,g,b]=img[x,y] 回答1: You can do everything you are wanting to do within PIL. If you are wanting to reduce the value of every