Best command for resizing large pics for highest quality.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
davidb2002
Posts: 37
Joined: 2008-09-01T08:31:26-07:00

Best command for resizing large pics for highest quality.

Post by davidb2002 »

I work on a photography website and need to resize user's photos down to photos that are no bigger than 600x600. The uploads are jpeg files and the current command I am using gives alot of artifacts. I have upped quality to 100 and although less artifiacts, still not as acurate as photoshop. Any suggestions on the best command to downsize high res photos (we are talking photos from Digital SLRs) for the most minimal amount of artifacts, distoration in colour, etc.

My Current command:

Code: Select all

/usr/bin/convert  -strip -geometry 600x600 -quality 85 '/temp/file.jpg' '/new/file.jpg'
Cheers for any help!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Best command for resizing large pics for highest quality

Post by fmw42 »

I am surprised that even works. -geometry is a setting and not an operator/option

try

convert image.jpg -strip -resize 600x600 -quality 85 result.jpg


you may want to look into profiles also (but I am no expert on that)

see http://www.imagemagick.org/Usage/formats/#profiles

see also http://www.imagemagick.org/Usage/basics/#why regarding order of items in command line
davidb2002
Posts: 37
Joined: 2008-09-01T08:31:26-07:00

Re: Best command for resizing large pics for highest quality

Post by davidb2002 »

I have tried with resize and the new order and I don't see any difference in quality. So I upped -quality to 100 and this does provide better quality, but the image appears darker then if I was to do it in photoshop.

I am basically trying to replicate what photoshop does when you resize a large image. Once I have done that, I need to concentrate on decreasing the filesize of the image.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Best command for resizing large pics for highest quality

Post by fmw42 »

I am told that photoshop may include an unsharp masking effect when resizing.
kankwayot

Re: Best command for resizing large pics for highest quality

Post by kankwayot »

You speak about downsized images that are darkened .. methinks that you will possibly find this link about gamma-aware resizing to be of interest :

http://www.4p8.com/eric.brasseur/gamma.html#ImageMagick

An ImageMagick command chiseled to satisfyingly downsize JPEG images is even provided !
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Best command for resizing large pics for highest quality

Post by magick »

The Eric Basseur article has a mistake. The option is -resize, not -scale. Only -resize accepts the -filter option.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Best command for resizing large pics for highest quality

Post by snibgo »

In my experience, IM doesn't darken images or introduce "lots of artifacts" when shrinking photos. (But very low JPEG quality values will introduce artifacts, of course.)

Can you link to examples, with the command(s) that created them? And what version of IM do you use?
snibgo's IM pages: im.snibgo.com
davidb2002
Posts: 37
Joined: 2008-09-01T08:31:26-07:00

Re: Best command for resizing large pics for highest quality

Post by davidb2002 »

Have tried that other command and thats really bad. It' lightens all the whites. The closest thing I have is my original command with quality 100. but colours (mainly reds) do appear slightly darker, especially around the edges.
davidb2002
Posts: 37
Joined: 2008-09-01T08:31:26-07:00

Re: Best command for resizing large pics for highest quality

Post by davidb2002 »

Here are some examples.

Photoshop resize and save @ 100%

Image

IM: origina.jpg -strip -resize 600x600 -quality 100 new.jpg

Image

Notice the differences in the Reds (particuarly, the red toy truck). ImageMagick 6.2.8 04/17/08 Q16
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Best command for resizing large pics for highest quality

Post by snibgo »

When I place those images side-by-side, I can't detect any difference. (They look different when placed vertically on LCD monitors, because LCD monitors do that.)

When I examine them with Gimp color picker, sample average, radius 20, on the red truck at location 261,82:

image 52194_1269256674.jpg reports rgb(129,59,53)
image original_testshot.jpg reports rgb(130,59,54)

My eyes can't detect a 1/255 difference in two of three channels.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Best command for resizing large pics for highest quality

Post by fmw42 »

using

compare -metric rmse testshot_im.jpg testshot_ps.jpg null:
792.999 (0.0121004)


This shows a 1.2% rmse difference. And as I mentioned before, I have been told that PS adds unsharp masking to its process of resizing to sharpen slightly.

Plus IM uses a different and probably better resize filter (Lanczos) and PS uses cubic convolution.

see

http://www.imagemagick.org/Usage/resize/#filter
http://www.imagemagick.org/Usage/resize/#photoshop
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Best command for resizing large pics for highest quality

Post by snibgo »

At 800% magnification, I can't see any unsharp masking in that PS image, compared to the IM version.

On a flicker comparison, I can't see any difference -- there is no flicker.

Incidentally, it may be worth upgrading IM that is a couple of years old.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Best command for resizing large pics for highest quality

Post by fmw42 »

Anthony mentioned the unsharp masking to me, but I have no other verification. The main issue, I think, would be different resizing filters used by IM and Photoshop. But you can choose matching filters (presumably matching by name), if you want to try that. See the IM page referenced and the -filter option set before -resize.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Best command for resizing large pics for highest quality

Post by fmw42 »

I can alternate (flicker) the two images in Mac Preview and the PS image is definitely darker. BUT flickering them with my flicker script in the IM display in X11, shows very little difference.

Might it be a profile difference?

Identify -verbose on the PS image shows profiles

Profiles:
Profile-8bim: 6592 bytes
Profile-exif: 6152 bytes
Profile-icc: 3144 bytes
IEC 61966-2.1 Default RGB colour space - sRGB
Profile-xmp: 5163 bytes


The IM image has no profiles.

Try stripping the profiles from the PS image or adding the profiles to the IM image.
davidb2002
Posts: 37
Joined: 2008-09-01T08:31:26-07:00

Re: Best command for resizing large pics for highest quality

Post by davidb2002 »

The trouble is that I need to not only replicate as close as I can to photoshop, but also keep filesize as small as possible too. So therefore we have added -strip for that reason. However, it's still much much bigger than a photoshoped version.

Any recommendatiosn on reducing filesize without reducing image quality too much?
Post Reply