[Addon] Image Resizer (requires pil!)

An image resizer addon for blender. Easily resize and save your images from blender.

It needs the Pillow(PIL) python module!

Github Repo

How to install Pillow to Blender?

Known Issues:

For now, this add on can not save 16 bit images. (pil does not support saving 16 bit images.)

Hi erdinc , very good job here, thanks for sharing your usefull job.

you must correct this, please:
$ sudo pip install -U pillow

to install with ‘root’ user privileges!

I will try just now…Thk and Congratulations :eyebrowlift:

Oh, ok. I corrected it :slight_smile: Thanks @Spirou4D .

erdinc, yu’re welcome!

I have installed Pillow for my python 2.75 on Linux Mint Rosa 64bytes but your script don’t see the pill module.

How copy it in my module folder of <Homer>/.config/blender/2.77/scripts/modules for my Blender 2.77a?

EDIT: I have copied the PIL folder (from /usr/lib/python2.7/dist-packages/ ) in my <home>/.config/blender/script/module folder but no found by your script.

For example in my distro, my system python’s site-package directory path is
/usr/lib64/python3.5/site-packages/
in it there is a PIL directory.
(/usr/lib64/python3.5/site-packages/PIL)
just copy it, or make a symlink to your
~/.config/blender/script/modules directory

to make a symlink from terminal (your paths may be different)

ln -s /usr/lib64/python3.5/site-packages/PIL ~/.config/blender/2.77/scripts/modules/

By the way your python version should be 3.5 if you re using Blender 2.77a .
A virtualenv python 3.5 installation would work too, It does not need to be system’s python.
I ll try to install the pip directly to the python which ships with blender. It may be more easier.

in my usr/lib/ (for 64bytes off’course) there are python2.6, python2.7, python3, python2.4, python3.5
the official version is python2.7
in his dist-package, i have PIL + PILcompat + Pillow-2.3.0.egg-info
I have placed all in my
~Home/.config/blender/script/module BUT no change!

in python3, there are a dist-package with the same file
PIL + Pillow-2.3.0.egg-info
I placed in the same config folder BUT no change!

Above 3.0=> python3.4 and python3.5 have not a dist-packages folder (?)
Their dist-packages must be elsewhere but where???

But for Linux Mint Rosa 17.3, there are already Python-PIL installed (Fork of PIL) :
a http://storage9.static.itmages.com/i/16/0712/h_1468332636_2131391_84c5723f6b.jpeg

Can I modify the call of PILL in your script, please?

I try with a terminal to see if PIL is installed on my system:
$ python
$>>>import PIL
no problem!

Erdinc, I have found a error here:


def unregister():
    del bpy.types.Scene.ImageResizer
    bpy.utils.unregister_module(__name__)
    del bpy.types.Scene.ImageResizer

Two time the " del bpy.types.Scene.ImageResizer"
An oversight may be…

============================================
Solutions:
I made as you said to create a link but no change with my blender.
I found this:
VERSION = ‘1.1.7’ # PIL version
PILLOW_VERSION = ‘2.3.0’ # Pillow
in Dist-packages of Python3

But in Blender console:
PYTHON INTERACTIVE CONSOLE 3.5.0 (default, Sep 17 2015, 00:00:00) [GCC 4.8.4]

>>> from PIL import Image
Traceback (most recent call last):
File “<blender_console>”, line 1, in <module>
File “/home/patrinux/.config/blender/2.77/scripts/modules/PIL/Image.py”, line 53, in <module>
from PIL import _imaging as core
ImportError: cannot import name ‘_imaging’

I HAVE FOUND THAT BLENDER load good PIL but something is missing for PIL to work in line 52 of the fist file image.py of PIL:
“from PIL import _imaging as core”

Of course, you can do whatever you want with it :slight_smile:

Also, thanks again i deleted the duplicated line.

Could you try again to put python 3 version of PIL directory to
~/.config/blender/scripts/modules ( script"s" , module"s" )

I will put an option to addon preferences to select PIL path hopefully soon.

– update

i believe there is a version mismatch.

could you run this code in your system python 3.5

import site; site.getsitepackages()

or this one

import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())

this should print the dist-packages or site-packages directories of python 3.5
and if there is PIL dir in one them copying that may work.

no no it’s good my uri is /home/patrinux/.config/blender/2.77/scripts/modules
I have made a link of PIL of Python3 but no change with Blender.

I have understood, it’s because PIL is compiled for python3 and not python 3.5:
When the image.py search this :
“from PIL import _imaging as core”
it’s in _imaging.cpython-34m-x86_64-linux-gnu.so, file compiled with python3 on my system and not with python3.5.

may be???

Yes exactly :slight_smile: you need python 3.5 version of PIL . We need to find your python 3.5 dist-packages dir. Then copy from there.

no no it’s good my uri is /home/patrinux/.config/blender/2.77/scripts/modules
I have made a link of PIL of Python3 but no change with Blender.

I have understood, it’s because PIL is compiled for python3 and not python 3.5:
When the image.py search this :
“from PIL import _imaging as core”
it’s in _imaging.cpython-34m-x86_64-linux-gnu.so, file compiled with python3 on my system and not with python3.5.

may be???

Yes absolutely! But where is it?

I try to install python3.5 completed (with Dev)

could you run this code in your system python 3.5

import site; site.getsitepackages()

or this one

import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())

this should print the dist-packages or site-packages directories of python 3.5
and if there is PIL dir in one them copying that may work.

Solution 1
[’/usr/local/lib/python2.7/dist-packages’, ‘/usr/lib/python2.7/dist-packages’]

Solution 2
/usr/lib/python2.7/dist-packages

My python version is:
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2

You should run them with python3.5
is python 3.5 installed in your system ?

call python from terminal with “python3.5” command
than execute the codes again please.

WARNING: Here is in OS Terminal:
Solution 1
[’/usr/local/lib/python2.7/dist-packages’, ‘/usr/lib/python2.7/dist-packages’]

Solution 2
/usr/lib/python2.7/dist-packages

My python version is python2.75

So erdinc, we move forward…I found the answer:
I type in Blender console your python question and here is the answer:
/usr/lib/python3/dist-packages and there are PIL there: 1.17 version!

Why your script or Blender don’t use PIL normally??? All is OK!