How to Remove 1 inch from bottom & 1/2 inch from each side

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
BradM
Posts: 8
Joined: 2012-05-29T16:56:27-07:00
Authentication code: 13

How to Remove 1 inch from bottom & 1/2 inch from each side

Post by BradM »

I just started working with Imagemagick today.

I understand some of the basics and I have run some successful tests.

However, I have not yet figured out things for the main reason that I am working with Imagemagick.

I have a large number of jpg files that are being generated by a purchased software package.

I would like to trim off 1 inch from the bottom of each image and 1/2 inch from both the left and right sides of each image.

I would guess that this is easy to do with Imagemagick, but I have not figured it out yet.

It would be much appreciated it some one would post an example of how to do this.

Thanks,
Brad
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to Remove 1 inch from bottom & 1/2 inch from each s

Post by anthony »

You would need to calculate the 'shave' to perform, based on the images resolution.

In IMv6 you will need to do that externally in a shell or DOS script wrapper.

IMv7 (still in alpha development) can do this more directly using %[fx:..] escapes in the operator option arguments.
I am working to allow the same global use of percent escapes in setting options to make it even more useful.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How to Remove 1 inch from bottom & 1/2 inch from each s

Post by Bonzo »

You could shave as Anthony says or crop. But images work in pixels and not inches so you will either need to experiment or calculate the amounts based to remove based on the DPI as Anthony also says.

Crop = 300x300+25+0 the final image will be 300px x 300px and 25px in from the left hand side and 0 from the top

Code: Select all

convert input -crop 300x300+25+25 +repage output
If you check out my site I have an example of most of the options using php but you can see an example and the related code you can modify.

You can also see information about all the operators here: http://www.imagemagick.org/script/comma ... eonsb3v9q6
BradM
Posts: 8
Joined: 2012-05-29T16:56:27-07:00
Authentication code: 13

Re: How to Remove 1 inch from bottom & 1/2 inch from each s

Post by BradM »

Thanks for the help, I really appreciate it.

I now have a working example of what I am trying to do.

Brad
Post Reply