Downsizing large JPEGS and maintaining 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?".
Post Reply
AakLak
Posts: 2
Joined: 2018-12-27T20:46:24-07:00
Authentication code: 1152

Downsizing large JPEGS and maintaining quality

Post by AakLak »

Trying to resize some large (~5593 × 3309) JPEGS into smaller thumbnails. Im on MacOS
Quality is important, as this is for a photography website.

I'm currently using: convert "$f" -resize 500x500 -quality 100 -density 300 -set filename:f "%[t]-thumb" "%[filename:f].jpg"
However I'm seeing inconsistent results, and some are of very poor quality (Lines are getting blurry/blocky, see ex2 below.)

Appreciate any suggestions, thank you!

Edit - More Info:
Most images are of architecture/interiors.

Example 1:
Original Image - https://www.rishulbangar.com/img/archit ... 83-min.jpg
Converted Image - https://www.rishulbangar.com/img/archit ... -thumb.jpg
Issue - Can see lots of distortion on the converted image. Would like for it to look crisp.
Can especially be seen on mobile phones.

Example 2:
Original - https://i.imgur.com/3B0Lfv4.jpg
Downsized - https://i.imgur.com/Z9FKrHx.jpg
Issue - Wood planks by the pool are no longer straight lines.


Thank you
Last edited by AakLak on 2019-01-03T03:46:07-07:00, edited 4 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Downsizing large JPEGS and maintaining quality

Post by fmw42 »

How are you judging the quality? From a digital display or from print. Changing the density will not change the quality of the output when viewing on a display. It will not improve the quality either by increasing the density. That will only enlarge the image on the print page.

What kind of images are you using? Are they natural scenes, graphics or line drawings? They type of image is important regarding which type of resizing filter you should use.

See

https://imagemagick.org/Usage/filter/
https://imagemagick.org/Usage/filter/nicolas/

In what way are they poor? Is it resolution/blurring or color changes. If the latter, you should include profiles in your processing.

_________________

Please, always provide your IM version and platform when asking questions, since syntax may differ.

Also provide your exact command line and your images, if possible.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Downsizing large JPEGS and maintaining quality

Post by snibgo »

Do they look blurry? Downsized photos often look better with some sharpening. I like the method shown at Resampling with halo minimization.
snibgo's IM pages: im.snibgo.com
AakLak
Posts: 2
Joined: 2018-12-27T20:46:24-07:00
Authentication code: 1152

Re: Downsizing large JPEGS and maintaining quality

Post by AakLak »

Updated OP with more info and example images.

Thanks @fmw42 and @snibgo. I'll try your suggestions.
Any further suggestions based on my sample images (in OP) would be appreciated.

Thank you.
mikmach
Posts: 42
Joined: 2015-02-06T07:50:43-07:00
Authentication code: 6789

Re: Downsizing large JPEGS and maintaining quality

Post by mikmach »

If you want to keep quality to 100 option `-sampling-factor 1x1` doesn't matter much but is always good thing to include it when dealing with JPGs.

Simple `-unsharp` will do miracles when downsizing. Parameters you have to choose according to your taste. For me `1x1` is good enough although some may find it as oversharpening.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Downsizing large JPEGS and maintaining quality

Post by fmw42 »

AakLak wrote: 2018-12-30T03:10:08-07:00 Updated OP with more info and example images.

Thanks @fmw42 and @snibgo. I'll try your suggestions.
Any further suggestions based on my sample images (in OP) would be appreciated.

Thank you.
I am not a photographer. So to me your downsized image looks fine. But other photographers may offer better suggestions than follows here.

I think it depends upon what you think is the issue. If you want more sharpness, you could try -filter catrom (though that is usually more relevant for upsizing). Or use -unsharp. If the issue is artifacts, then use some of the suggestions for downsizing from Nicolas Robidoux at https://imagemagick.org/Usage/filter/nicolas/. But note that JPG is a lossy compression even at -quality 100. Can you not use some other non-lossy compressed file such as PNG or TIFF or JP2000?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Downsizing large JPEGS and maintaining quality

Post by snibgo »

Another downsize-sharpen method I like is Limit min-max. This can sharpen without halos, and also without aliasing (aka jaggies, staircasing).

Of course, you wouldn't start from JPG inputs.
snibgo's IM pages: im.snibgo.com
Post Reply