Page 1 of 1

Cropping Image

Posted: 2011-04-08T04:05:07-07:00
by starsnip
Hi Guys,

Apologies if this is simple, but I'm trying to call ImageMagick from a command line in VB (little irrelevant!)

I would like to crop the image, and save the image as the current file name. I'm assuming from the docs I need the -shave command line argument but here's where I think it gets complicated.

Some of my images are the correct size, and some are not. I would like ImageMagick to be able to take the sides from the image (i.e. make it 480 x 640) as long as it is a predefined image size (i.e. if it's 1024 x 768 - then -shave - otherwise leave it alone!)

If you're still reading this, the application is for photo ID, and the webcam we're using (after switching) only takes landscape pics, and the end user wants portrait - as all of their current images are portrait... hence the need to not crop or shave their current images (which although they are portrait, they are of no fixed size) - therefore the only way of determining which is a new image is the dimensions of the image.

If you can help, thanks a million - and thanks for even just reading this far!

All the best,
Pete

Re: Cropping Image

Posted: 2011-04-08T10:29:20-07:00
by fmw42
Depending upon what parts you want to remove, your choices are -crop, -shave or -chop. see http://www.imagemagick.org/Usage/crop/ and look further downs for -shave and -chop.

Unfortunately, IM has no internal ability (to my knowledge) to test for image size (except in -resize). Therefore you will need to do that test in VB prior to calling your IM command. However, I am not a Windows/VB user, so cannot advise further. You may find some help in http://www.imagemagick.org/Usage/windows/