标签: pillow

什么是最内在的括号?

thumbnail()在Pillow(PIL)模块中使用该方法时,必须遵循以下约定,其中使用两组(嵌套)括号:

pil_image.thumbnail((128,128))
Run Code Online (Sandbox Code Playgroud)

如果只使用一个集合,Python会生成以下错误:

TypeError: 'int' object is not subscriptable

最里面的括号是否有正式名称?

PS:以下也有效:

box = 128, 128 # No parentheses needed.
pil_image.thumbnail(box)
Run Code Online (Sandbox Code Playgroud)

另外:Python解析器的一部分缺点是无法在这里弄清楚意图吗?

python python-2.7 pillow

2
推荐指数
1
解决办法
282
查看次数

安装枕头(和PIL)时出错

如果我使用该命令sudo pip install Pillow,它运行正常,直到清理阶段:(这是来自日志文件的完整错误消息)

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1

----------------------------------------

Cleaning up...
Removing temporary dir /private/tmp/pip_build_root...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip_build_root/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-VaD2jT-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/Pillow
Exception information:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 122, in main …
Run Code Online (Sandbox Code Playgroud)

python python-imaging-library pillow

2
推荐指数
1
解决办法
6962
查看次数

Pillow不支持JPEG支持 - 安装Django Cms

我正在尝试让Django Cms在我的系统上工作.遵循Django-CMS教程:https://github.com/divio/django-cms-tutorial

我不得不安装枕头,但现在我跑的时候:

$ djangocms -p . my_demo
Run Code Online (Sandbox Code Playgroud)

并填写所有选项我收到以下错误:

HTTP error 404 while getting https://github.com/divio/django-cms/archive/3.0c2.zip
Exception:
Traceback (most recent call last):
  File "/Users/macbook/Desktop/MyProjects/djangoCMS/demo/demoEnv/lib/python2.7/site-    packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
  File "/Users/macbook/Desktop/MyProjects/djangoCMS/demo/demoEnv/lib/python2.7/site-    packages/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/Users/macbook/Desktop/MyProjects/djangoCMS/demo/demoEnv/lib/python2.7/site-packages/pip/req.py", line 1197, in prepare_files
do_download,
  File "/Users/macbook/Desktop/MyProjects/djangoCMS/demo/demoEnv/lib/python2.7/site-packages/pip/req.py", line 1375, in unpack_url
self.session,
  File "/Users/macbook/Desktop/MyProjects/djangoCMS/demo/demoEnv/lib/python2.7/site-packages/pip/download.py", line 547, in unpack_http_url
resp.raise_for_status()
  File "/Users/macbook/Desktop/MyProjects/djangoCMS/demo/demoEnv/lib/python2.7/site-packages/pip/_vendor/requests/models.py", line 773, in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 404 Client Error: Not …
Run Code Online (Sandbox Code Playgroud)

macos libjpeg django-cms pillow

2
推荐指数
1
解决办法
1773
查看次数

Django Pillow/PIL错误

我正在尝试使用Django教程进行探戈,该教程使用django 1.5.我正在使用virtualenvwrapper.我用pip安装了Pillow.

$ pip freeze
Django==1.5.5 
Pillow==2.4.0 
South==0.8.4 
wsgiref==0.1.2. 

(tangowithdjango)~/dev_django_projects/tangowithdjango$ which python
 /Users/7stud/.virtualenvs/tangowithdjango/bin/python
(tangowithdjango)~/dev_django_projects/tangowithdjango$ python --version
Python 2.7.6
Run Code Online (Sandbox Code Playgroud)

但是,在第8章中我收到以下错误:

(tangowithdjango)~/dev_django_projects/tangowithdjango$ ./manage.py syncdb 
Run Code Online (Sandbox Code Playgroud)

CommandError:一个或多个模型未验证:rango.userprofile:"picture":要使用ImageFields,您需要安装Python Imaging Library ...

我无法安装PIL,这就是我安装Pillow的原因:

(tangowithdjango)~/dev_django_projects/tangowithdjango$ pip install PIL
Downloading/unpacking PIL
  Could not find any downloads that satisfy the requirement PIL
  Some externally hosted files were ignored (use --allow-external PIL to allow).
Cleaning up...
No distributions at all found for PIL
Storing debug log for failure in /Users/7stud/.pip/pip.log
Run Code Online (Sandbox Code Playgroud)

当我尝试:

$ pip install Pillow-PIL 
Run Code Online (Sandbox Code Playgroud)

应该将buggy import语句转换为良好的import语句,我得到错误:

找不到满足Pillow-PIL要求的版本(版本:0.1dev)

最后,如果我尝试在shell中使用PIL:

(tangowithdjango)~/dev_django_projects/tangowithdjango$ …
Run Code Online (Sandbox Code Playgroud)

django python-imaging-library pillow

2
推荐指数
1
解决办法
3453
查看次数

Python3 PIL Pillow Ubuntu安装

我正在运行Ubuntu 14.04 LTS.我安装了Python 2.7和Python 3.4.在Linux中安装Python软件包时,我相对比较新手.

我只是想在Python 3.4中安装并访问PIL的图像库.我的理解是,这是通过安装PIL的现代分支Pillow来实现的.

在我的挣扎中似乎成功地让PIL在Python 2.7中工作,但我仍然无法在3.4中使用它.

我得到了pippip3.当我进入

sudo pip3 install Pillow
Run Code Online (Sandbox Code Playgroud)

我收到以下错误消息,暗示它已安装:

Requirement already satisfied (use --upgrade to upgrade): Pillow in /usr/local/lib/python3.4/dist-packages
Cleaning up...
Run Code Online (Sandbox Code Playgroud)

然而,当我尝试在Python 3.4中导入PIL或Pillow时,找不到该模块.

我觉得我只是缺少一些简单的东西.

installation ubuntu python-imaging-library pillow python-3.4

2
推荐指数
1
解决办法
1万
查看次数

为什么PIL /枕式作物不起作用?

我正在尝试使用枕头来裁剪图像,但是它似乎不起作用。我有以下代码:

im = Image.open('the_image.jpg')
print 'ORIGINAL SIZE: ', im.size
im.crop((1087, 0, 1820, 2197))
print 'CROPPED SIZE: ', im.size
Run Code Online (Sandbox Code Playgroud)

在终端上打印此:

ORIGINAL SIZE:  (2908, 2197)
CROPPED SIZE:  (2908, 2197)
Run Code Online (Sandbox Code Playgroud)

有人知道为什么种植似乎无效吗?欢迎所有提示!

python image crop python-imaging-library pillow

2
推荐指数
1
解决办法
906
查看次数

在Raspberry Pi上安装Pillow时出错

我只是想在我的新Raspberry Pi上安装yowsup.一切都很顺利,直到它要安装Pillow.我收到以下错误消息:

Processing dependencies for yowsup2==2.4
Searching for pillow
Reading http://pypi.python.org/simple/pillow/
Best match: Pillow 3.0.0
Downloading https://pypi.python.org/packages/source/P/Pillow/Pillow-3.0.0.zip#md5=dd81f6cc3f3a5e5fe72f0f1d936339c3
Processing Pillow-3.0.0.zip
Running Pillow-3.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-AlZEzs/Pillow-3.0.0/egg-dist-tmp-rX2XN3
Exception in thread Thread-1 (most likely raised during interpreter shutdown):Exception in thread Thread-2 (most likely raised during interpreter shutdown):
Traceback (most recent call last):

  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_innerTraceback (most recent call last):

  File "/usr/lib/python2.7/threading.py", line 505, in run  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner

  File "/usr/lib/python2.7/multiprocessing/pool.py", line 353, in _handle_tasks  File "/usr/lib/python2.7/threading.py", line …
Run Code Online (Sandbox Code Playgroud)

python raspberry-pi pillow

2
推荐指数
1
解决办法
7828
查看次数

使用Boto将枕头文件保存到S3

我通过s3boto将Amazon S3用作存储后端。我有一个带有ImageField的Image模型。通过管理员上传图像后,该图像将成功上传到S3。我现在想做的是使用Pillow创建缩略图后保存。我已经通过在其上调用show()方法验证了缩略图已创建,但是由于某种原因它没有被上传到S3。我认为我的保存方式可能​​是错误的-任何建议请多加赞赏。

task.py

from celery import shared_task
from .models import Image
import os
from django.core.files.storage import default_storage as storage
from PIL import Image as PillowImage

@shared_task
def create_thumbnails(pk):
    try:
        image = Image.objects.get(pk=pk)
    except Image.ObjectDoesNotExist:
        pass
    thumbnail_size = (450,200)
    filename, ext = os.path.splitext(image.image.name)
    try:
        fh = storage.open(image.image.name, 'r')
        im = PillowImage.open(fh)
        im.thumbnail(thumbnail_size)
        im.show() # TEST - This opens the resized image in Preview on my mac
        filename = filename +'_thumbnail' +ext
        new_file = storage.open(filename, 'w')
        im.save(new_file, "PNG")
        new_file.close()
    except IOError as …
Run Code Online (Sandbox Code Playgroud)

django amazon-s3 pillow

2
推荐指数
1
解决办法
2850
查看次数

Python枕头如何拍摄屏幕截图或将文本转换为图像

美好的一天。

在我的工作中,有时我必须使用脚本从数字或ID中获取一些信息。就像下面的例子:

我使用的脚本:

$sh script.sh 9999999999999 abc    
Run Code Online (Sandbox Code Playgroud)

屏幕上显示的信息:

number: 9999999999999

SQL*Plus: Release 1.2.3.4 Production on Wed Jan 10 12:35:22 2017

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database Enterprise Edition Release 1.2.3.4 - 32bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


NUMBER||','||SERVICE||','||CONTRACT_DATE||','||COMFIRMATION
--------------------------------------------------------------------------------
9999999999999,SERVICE_NAME_1,01-OCT-13 10.44.30 AM,Y
9999999999999,SERVICE_NAME_2,08-DEZ-14 09.52.57 AM,N
9999999999999,SERVICE_NAME_3,26-FEB-16 11.42.30 AM,Y

Disconnected from Oracle Database Enterprise Edition Release 1.2.3.4 - 32bit Production
With the Partitioning, OLAP, Data Mining and Real …
Run Code Online (Sandbox Code Playgroud)

python pillow

2
推荐指数
1
解决办法
5696
查看次数

获取文件的md5而不保存在光盘上

我正在使用枕头编辑图像,编辑后我使用方法保存并在保存的文件上下一次计数md5.保存文件需要0.012秒,对我来说太长了.有没有办法在Image对象上计算md5而不保存到文件?

python md5 pillow

2
推荐指数
1
解决办法
506
查看次数