[Image-SIG] Resizing images
jb at langarson.com.au
Fri Feb 23 00:07:04 CET 2007
Chris MacKenzie wrote:
> I am doing a vast amount of work in photoshop cs2 and then resizing
> images into multiple sizes for email, web publication, printing out on
> A3, A4 etc,etc. To date I have been using PhotoShop actions which is a
> real pain.
> I have used PIL with python in a programming environment and am aware of
> the power it gives.
> My Question is will resizing in PIL reduce the image quality compared to
> CS2 or will it remain the same as the CS2 output.
The main differences (barring bugs/odd implementations) will be the
different interpolation methods available to you.
Just looking in CS2 the standard ones are :
You can also find a whole lot of discussion on the web about Photoshop
actions that given better resizing, in particular 'Stair Interpolation'
which is basically changing the size by small amounts and repeating
until you reach the desired size. This will take a lot more CPU time,
but is meant to give better results. eg http://www.fredmiranda.com/SI/
Looking at PIL and the resize function we have the following methods :
NEAREST (use nearest neighbour),
BILINEAR (linear interpolation in a 2x2 environment),
BICUBIC (cubic spline interpolation in a 4x4 environment), or
ANTIALIAS (a high-quality downsampling filter)
I would expect that the first three should produce identical results to
Photoshop, though there could be some variation to the implementation of
the algorithm in some methods. You could confirm this and otherwise see
how the other versions from the two compare.
The main thing might be that python/PIL is perhaps a bit slower, but if
you don't have too many images, or they aren't too big, and can easily
script it to take less of your time, then you should win out on time.
If desired you should be able to replicate the Stair Interpolation
method within PIL fairly easily, I have done before, but can't find the
code right now.
A separate note on getting the best out of resizing for email/web is
that it is a good idea to sharpen the image with an unsharp mask after
it has been resized. This makes a very marked difference to the end
result. If you have a search for "resize image unsharp" on google to
find some further discussion.
Here is one :
This leaves PIL at a little bit of a disadvantage as there isn't a
default unsharp mask in PIL, but there was a plugin/patch built for it!
It was for an older version, but I think I had it working ok with at
least 1.1.4, and probably wouldn't take much to get to work with 1.1.6
if it didn't work as is :
Hope this helps,
More information about the Image-SIG