Possible to tell if an image is a drawing?

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
theosophe74

Possible to tell if an image is a drawing?

Post by theosophe74 »

My application needs to create thumbnails from uploaded images. They can be in gif, jpg, png 8~bit, or png 24~bit format. We will be displaying all thumbnails within the application in a 3:2 aspect ratio. But with images that are drawings, especially those that are logos in a 1:1 ratio, cropping them makes them look awful, especially if they take up the entire canvas.

Can anyone think of a way to know when I should pad out the image instead of shrink the image to fit? Is there a way to know whether an image is a drawing? Is it enough to know that it is 1:1 to know that it should probably be padded out? Should we just not allow images that are not 3:2?

Thanks in advance for any input.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible to tell if an image is a drawing?

Post by fmw42 »

It is a bit tricky. You need to know the width and height and then compute the aspect of the image and compare that to the desired aspect. You may also have to deal with 2:3 (portrait) rather than 3:2 (landscape).

See my bash unix scripts aspectpad and aspect at the link below.
Last edited by fmw42 on 2010-02-23T18:09:22-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Possible to tell if an image is a drawing?

Post by snibgo »

I don't really understand the problem. Why not pad all the uploaded images to 3:2 aspect ratio?

Trying to get ImageMagick (or other software) to determine whether trimming an image would make it "look awful" sounds like a hard problem.

Can you post examples of images that can, or shouldn't, be trimmed? Perhaps we can work something out.
snibgo's IM pages: im.snibgo.com
Post Reply