pillow

Installing Pillow with Mac OS X Mavericks (10.9.1)

拟墨画扇 提交于 2019-12-18 08:44:28
问题 I'm trying to install Pillow following the instruction: http://pillow.readthedocs.org/en/latest/installation.html#mac-os-x-installation The issue is that I got error with python -c 'from PIL import Image . python -c "from PIL import Image" Traceback (most recent call last): File "<string>", line 1, in <module> File "/Library/Python/2.7/site-packages/PIL/Image.py", line 53, in <module> from PIL import _imaging as core ImportError: dlopen(/Library/Python/2.7/site-packages/PIL/_imaging.so, 2):

How can I display an image using Pillow?

孤者浪人 提交于 2019-12-18 03:18:05
问题 I want to display a gif image using Pillow Here is my simple code: from tkinter import * from PIL import Image, ImageTk import tkinter as Tk image = Image.open("Puissance4.gif") image.show() But nothing happens... All help will be appreciated Thanks! 回答1: PIL provides a show method which attempts to detect your OS and choose an appropriate viewer. On Unix it tries calling the imagemagick command display or xv . On Macs it uses open , on Windows it uses... something else. If it can't find an

Getting “cannot write mode P as JPEG” while operating on JPG image

做~自己de王妃 提交于 2019-12-18 03:01:02
问题 I am trying to resize some images, most of which are JPG. But in a few images, I am getting the error: Traceback (most recent call last): File "image_operation_new.py", line 168, in modifyImage tempImage.save(finalName); File "/Users/kshitiz/.virtualenvs/django_project/lib/python2.7/site- packages/PIL/Image.py", line 1465, in save save_handler(self, fp, filename) File "/Users/kshitiz/.virtualenvs/django_project/lib/python2.7/site- packages/PIL/JpegImagePlugin.py", line 455, in _save raise

Python/PIL affine transformation

风格不统一 提交于 2019-12-17 22:53:42
问题 This is a basic transform question in PIL. I've tried at least a couple of times in the past few years to implement this correctly and it seems there is something I don't quite get about Image.transform in PIL. I want to implement a similarity transformation (or an affine transformation) where I can clearly state the limits of the image. To make sure my approach works I implemented it in Matlab. The Matlab implementation is the following: im = imread('test.jpg'); y = size(im,1); x = size(im,2

Getting error while running django-cms demo page

爱⌒轻易说出口 提交于 2019-12-17 17:46:16
问题 I tried all of the procedure for installing django-cms, after that when i try to run a demo page i getting the below error. (djvenv2)shan@shan:~/workspace/projects/djvenv$ pip freeze Django==1.6.2 PIL==1.1.7 Pillow==2.4.0 South==0.8.4 argparse==1.2.1 dj-database-url==0.3.0 django-classy-tags==0.5.1 django-cms==3.0 django-mptt==0.6.0 django-sekizai==0.7 djangocms-admin-style==0.2.2 djangocms-installer==0.4.1 html5lib==0.999 six==1.6.1 wsgiref==0.1.2 (djvenv2)shan@shan:~/workspace/projects

Importing images from a directory (Python) [closed]

…衆ロ難τιáo~ 提交于 2019-12-17 10:52:37
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . Is there any way to import all the images inside a directory (the directory location is known). If it helps, I have already found a way of finding out the length of the directory. What I'm not sure about is how I can import the images (using PIL/Pillow) into either a list or a dictionary. 回答1: I'd

PIL cannot identify image file for io.BytesIO object

…衆ロ難τιáo~ 提交于 2019-12-17 07:33:07
问题 I am using the Pillow fork of PIL and keep receiving the error OSError: cannot identify image file <_io.BytesIO object at 0x103a47468> when trying to open an image. I am using virtualenv with python 3.4 and no installation of PIL. I have tried to find a solution to this based on others encountering the same problem, however, those solutions did not work for me. Here is my code: from PIL import Image import io # This portion is part of my test code byteImg = Image.open("some/location/to/a/file

Open PIL image from byte file

别等时光非礼了梦想. 提交于 2019-12-17 07:22:06
问题 I have this image with size 128 x 128 pixels and RGBA stored as byte values in my memory. But from PIL import Image image_data = ... # byte values of the image image = Image.frombytes('RGBA', (128,128), image_data) image.show() throws the exception ValueError: not enough image data Why? What am I doing wrong? 回答1: You can try this: image = Image.frombytes('RGBA', (128,128), image_data, 'raw') Source Code: def frombytes(mode, size, data, decoder_name="raw", *args): param mode: The image mode.

Open PIL image from byte file

我的未来我决定 提交于 2019-12-17 07:21:52
问题 I have this image with size 128 x 128 pixels and RGBA stored as byte values in my memory. But from PIL import Image image_data = ... # byte values of the image image = Image.frombytes('RGBA', (128,128), image_data) image.show() throws the exception ValueError: not enough image data Why? What am I doing wrong? 回答1: You can try this: image = Image.frombytes('RGBA', (128,128), image_data, 'raw') Source Code: def frombytes(mode, size, data, decoder_name="raw", *args): param mode: The image mode.

Cannot use im.getcolors

痞子三分冷 提交于 2019-12-13 20:04:23
问题 I was trying this code: im = Image.open("myimage") colors = im.getcolors() print colors and it returns "None". So I tried this: im = Image.open("myimage") size = im.size colors = im.getcolors(size[0]*size[1]) and when I "print colors" with this, Python basically crashes. I'm not using a huge image. How can I make it work? My goal is to know from an image how many pixels are closer to black and how many px are closer to white. Maybe im.getcolors it's not the right solution? 回答1: The image has