List Info

Thread: Resizing images




Resizing images
country flaguser name
United Kingdom
2007-02-20 22:17:06
Hi,
 
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.
 
Thanks in advance
 
 
Regards & best wishes
 
Re: Resizing images
user name
2007-02-22 08:58:33
On 2/20/07, Chris MacKenzie <chrissunnyneuk.com> 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.

> My Question is will resizing in PIL reduce the image
quality compared to CS2
> or will it remain the same as the CS2 output.

I'm not a hard-core pil dev/user, but I've been in the same
boat as
you, so here's my thoughts:

With Photoshop you'll be working from high-res, lossless
files (PSDs).
If you were to save them out as a high-res jpg and then
resize that
into smaller files with PIL, you'd definitely loose some
quality,
since PIL's source material (JPGs) will be of lower
quality.

If you give PIL a non-lossless format, like 24/32b PNGs and
you resize
to even multiples of the source image's size (for example,
800x600 -->
400x300 --> 200x150 --> 100x75) I suspect you'd get
pretty similar
results.

Where Photoshop shines, in my experience, is:
 * resizing to non-even multiple of source image's size
(800x600 --> 90x68)
 * using masks to define different compression ratios for
different
parts of the image
 * choosing the best compression ratio to match your desired
output size/quality

This is just a guess though. Since Photoshop is a
proprietary program,
no one outside Adobe can be confident about what goes on
inside its
"save optimized" code. Maybe PIL can do better!

Also, different types of photos may be affected differently
by the
various programs. Line-art may look rotten and photos may
look superb.
You could batch them and then fix up anything that doesn't
look good
enough.

By the way, I'm surprised you felt using actions a pain...
don't you
just drop a folder of images onto your action's
"droplet" .exe file? I
don't use cs2, so maybe they've taken droplets out.
-- 
Matthew Nuzum
www.bearfruit.org
newz2000 on freenode
_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig

Re: Resizing images
user name
2007-02-22 10:45:37
Well, the only way to know for sure is to try it... you
could probably
whip up a quick and dirty solution in 1-2 hours.

And, while I'm sure PIL is as good or better than
ImageMagick,
different algorithms can sometimes produce different
results, so you
want to try it out too to see which works best for your
art.

By the way, I don't know what's going on behind the scenes
here, but
he obviously uses Python, so maybe PIL too. This is a cool
project,
though not OSS: http://snipshot.com/

On 2/22/07, Chris MacKenzie <chrissunnyneuk.com> wrote:
> Hi Mathew,
>
> Thanks for helping out. Yeah you can do the old droplet
thing.
>
> In my limited experience of CS2, though, I define a new
resize action if I
> want to modify an existing one.
>
> Also, I have two sets of actions one for portrait and
one for landscape
> images to produce the same four constants; A3, A4,
Email, Web and I want to
> add ebay and Alamay.
>
> Also, things just seem to get a bit too cluttered for
my ordered world.
>
> It just seems cool and simple in my programmers brain
if everything is in a
> python script or similar that checks out width >
height and uses the correct
> sizes.
>
> Chris
>
>
> ----- Original Message -----
> From: "Matthew Nuzum" <newzbearfruit.org>
> To: "Chris MacKenzie" <chrissunnyneuk.com>
> Cc: <image-sigpython.org>
> Sent: Thursday, February 22, 2007 2:58 PM
> Subject: Re: [Image-SIG] Resizing images
>
>
> > On 2/20/07, Chris MacKenzie <chrissunnyneuk.com> 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.
> >
> >> My Question is will resizing in PIL reduce the
image quality compared to
> >> CS2
> >> or will it remain the same as the CS2 output.
> >
> > I'm not a hard-core pil dev/user, but I've been in
the same boat as
> > you, so here's my thoughts:
> >
> > With Photoshop you'll be working from high-res,
lossless files (PSDs).
> > If you were to save them out as a high-res jpg and
then resize that
> > into smaller files with PIL, you'd definitely
loose some quality,
> > since PIL's source material (JPGs) will be of
lower quality.
> >
> > If you give PIL a non-lossless format, like 24/32b
PNGs and you resize
> > to even multiples of the source image's size (for
example, 800x600 -->
> > 400x300 --> 200x150 --> 100x75) I suspect
you'd get pretty similar
> > results.
> >
> > Where Photoshop shines, in my experience, is:
> > * resizing to non-even multiple of source image's
size (800x600 --> 90x68)
> > * using masks to define different compression
ratios for different
> > parts of the image
> > * choosing the best compression ratio to match
your desired output
> > size/quality
> >
> > This is just a guess though. Since Photoshop is a
proprietary program,
> > no one outside Adobe can be confident about what
goes on inside its
> > "save optimized" code. Maybe PIL can do
better!
> >
> > Also, different types of photos may be affected
differently by the
> > various programs. Line-art may look rotten and
photos may look superb.
> > You could batch them and then fix up anything that
doesn't look good
> > enough.
> >
> > By the way, I'm surprised you felt using actions a
pain... don't you
> > just drop a folder of images onto your action's
"droplet" .exe file? I
> > don't use cs2, so maybe they've taken droplets
out.
> > --
> > Matthew Nuzum
> > www.bearfruit.org
> > newz2000 on freenode
> >
>
>
>
>


-- 
Matthew Nuzum
www.bearfruit.org
newz2000 on freenode
_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig

Re: Resizing images
country flaguser name
Australia
2007-02-22 17:07:04
Hi Chris,

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 :

Nearest Neighbour
Bilinear
Bicubic
Bicubic Smoother
Bicubic Sharper

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 :
http://www.cambridgeincolour.com/tutorials/im
age-resize-for-web.htm

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 :

See :

http://www.
cazabon.com/pyCMS/PIL_usm.html

Hope this helps,

JB.
_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig

Re: Resizing images
country flaguser name
New Zealand
2007-02-22 17:57:16
Chris MacKenzie wrote:

>> My Question is will resizing in PIL reduce the
image quality compared to 
>> CS2 or will it remain the same as the CS2 output.

I don't know about Photoshop, but this thread

http://mail.python.org/pipermail/image-sig/2005-M
ay/003310.html

will tell you that this function:

def stretch(im, size, filter=Image.NEAREST):
    im.load()
    im = im._new(im.im.stretch(size, filter))
    return im

gives pixel-identical results to the Gimp's best resize
method, if you
use PIL 1.1.6.  With 1.1.5, the results might be offset by
half a pixel,
but you won't notice that unless you are making very small
images.

If you don't actually need identical results, but are happy
enough with
something that looks fine, then im.resize(size,
Image.ANTIALIAS) should
work.

John Barratt wrote:

> 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. 

Actually this isn't the case -- apart from ANTIALIAS, the
PIL resize
modes are bad at downsampling.


douglas


_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig

[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )