Page 1 of 1

Possible to tell if an image is a drawing?

Posted: 2010-02-23T07:48:25-07:00
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.

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

Posted: 2010-02-23T10:40:12-07:00
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.

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

Posted: 2010-02-23T13:55:05-07:00
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.