Automatically sharpen images on resize

nicokaiser

Joined: 2004-10-04
Posts: 118
Posted: Fri, 2007-06-29 12:24

Hi!

Recently I looked at some images on Flickr and I realized that Flickr sharpens images when they are resized. This makes them look quite crisp and I thought if there would be a way to do this with ImageMagick and Gallery.
(compare http://www.flickr.com/photos/nicokaiser/tags/london/ and http://siriux.net/photos/reisen/london/ for example)

The ImageMagick convert's parameters "-filter Lanczos -unsharp 0x0.6+1.0 -resize ..." do a quite decent job, I wonder if this can be implemented (rather hardcore patch or maybe a configuration option?) in Gallery so all pictures are sharpened if they are resized with ImageMagic.

Has anyone an idea how to realize this?

Nico

Login or register to post comments
valiant

Joined: 2003-01-04
Posts: 32322
Posted: Fri, 2007-06-29 12:38

you're not the first to suggest this change. ideally, we'd expose more IM functionality and not hardcode a specific kernel / filter.

anyway, you can accomplish this by changing modules/imagemagick/classes/ImageMagickToolkit.class.
take a look at some existing code to understand how to add params to the exec() call. it's a bit unintuitive, but still quite simple.

related request:
- http://gallery.menalto.com/sfvote/vote/1312960

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

Login or register to post comments
nicokaiser

Joined: 2004-10-04
Posts: 118
Posted: Tue, 2007-07-24 20:39

Ok. I make a quick an dirty workaround for this that works quite well until Gallery does support sharpening options (sorry, it's in German only for now):

http://siriux.net/news/2007/06/30/schaerfer/#comment-6129

Login or register to post comments
Dayo

Joined: 2005-11-04
Posts: 487
Posted: Wed, 2007-07-25 00:49

Kaiser.

Any chance of translating it to English?

Thanks
.
Gallery version = 2.2.2
Default theme = PGtheme 1.3.0
Web Site: dakanji.com

Login or register to post comments
Dayo

Joined: 2005-11-04
Posts: 487
Posted: Wed, 2007-07-25 15:40

OK managed to figure it out.

Steps

01) open: modules/imagemagick/classes/ImageMagickToolkit.class
02) find: ? array('-size', $size, '-geometry', $size)
03) change to: ? array('-size', $size, '-geometry', $size, '-filter', 'Lanczos', '-unsharp', '0x0.6+0.8')
04) rebuild thumbnails / resizes

Copy attached if perfered. Change to .class

Valiant
Something to update in the module?

WARNING!
This is a one size fits all sharpening. Prefer to sharpen my images to taste before uploading. Some need a small amount and some need more. I find that properly sharpened images carry through rather well and produce consistent results while this improves some images and degrades others.

I am changing the 0.8 to 0.2 or 0.1 for minimal sharpening and may even dactivate it.

.
Gallery version = 2.2.2
Default theme = PGtheme 1.3.0
Web Site: dakanji.com

AttachmentSize
ImageMagickToolkit .txt20 KB
Login or register to post comments
nicokaiser

Joined: 2004-10-04
Posts: 118
Posted: Wed, 2007-07-25 16:19

Absolutely, it's a one-size-fits-all "quick & dirty" solution. But since I upload my images at 1024x1024 (no sharpening, only the camera's settings) and display them at 600x600 my values look quite good to me. And as I keep the unedited 1024-originals I can easily change or remove the setting later and recalculate the derivates.

Login or register to post comments
skunker

Joined: 2005-02-04
Posts: 247
Posted: Fri, 2007-11-16 18:56

hey guys, this is great...but is this also sharpening the original images that are uploaded? I just wanted to sharpen the THUMBNAIL and RESIZED versions, not the originals. Thanks for any clarification.

Login or register to post comments
nicokaiser

Joined: 2004-10-04
Posts: 118
Posted: Fri, 2007-11-16 22:17

This is sharpeing all pictures when (if) they are processed by ImageMagick. So whenever a picture is resized, the resized result will be sharpened. This can lead to over-sharpening if you have a dimension limit, i.e. all big pictures are resized e.g. to 1024 on upload. Then later the resized images (e.g. 500x500) are sharpened again (as the original uploads were deleted in this case).

Login or register to post comments