Windows Batch Crop

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
lionelthomas
Posts: 6
Joined: 2015-07-03T10:06:03-07:00
Authentication code: 1151

Windows Batch Crop

Post by lionelthomas »

I am new to Imagemagick and command line processing.
I have scanned a batch of 60 photos 3 at a time into a folder named Xinput and now want to crop out and possibly rotate the photos into another folder named Xoutput. The following command seems to work to crop out one photo but how do I crop the other 2 in one pass.

mogrify -path Xoutput -crop 1174x1760+0+0 Xinput/*

Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Windows Batch Crop

Post by snibgo »

I don't understand "60 photos 3 at a time". Does this mean you simply have 180 image files in that folder?

Do you want to give all these 180 images exactly the same crop and rotation?
snibgo's IM pages: im.snibgo.com
lionelthomas
Posts: 6
Joined: 2015-07-03T10:06:03-07:00
Authentication code: 1151

Re: Windows Batch Crop

Post by lionelthomas »

Each scan has 3 photos in it resulting in a jpg file with 3 photos in it. I want to crop and rotate the 3 photos into 3 separate files. 20 files in and 60 files out. Hope this explains better.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Windows Batch Crop

Post by fmw42 »

Use mogrify 3 times on the same folder, each time using a different set of crop coordinates. Write the results to 3 different folders so you do not write over the images. Then rename the images as desired before combining them.
lionelthomas
Posts: 6
Joined: 2015-07-03T10:06:03-07:00
Authentication code: 1151

Re: Windows Batch Crop

Post by lionelthomas »

Thanks, that would work except if I scan a roll of 36 photos they are now out of sequence. Is there a way to name the output files "rollnameXX1" where XX is photo number for the output folder 1 and so on. Then when I merge them into one folder they would be in sequence.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Windows Batch Crop

Post by snibgo »

If you want to change filenames, you can either do that part separately in a script that renames or copies or moves files, or do multiple (20 or 60) convert commands, probably in a loop in a script.
snibgo's IM pages: im.snibgo.com
lionelthomas
Posts: 6
Joined: 2015-07-03T10:06:03-07:00
Authentication code: 1151

Re: Windows Batch Crop

Post by lionelthomas »

Wow! This should be simple!! Where do I learn scripts? Seems like I have to become a programmer to use ImageMagick.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Windows Batch Crop

Post by fmw42 »

mogrify only makes one output for each input image in the folder. So no way to name the output files. But if you do what I say, you get a folder for each crop with the same name as the input. All you need to do is rename the files in each folder with a -1, -2, -3 before the suffix, then put all the files into one folder.

There should be renaming tools in Windows or, if not, you can probably find some separate tools to do that by searching Google

Alternately, learn batch scripting for windows and just use a For loop. Some pointers can be found at http://www.imagemagick.org/Usage/windows/
lionelthomas
Posts: 6
Joined: 2015-07-03T10:06:03-07:00
Authentication code: 1151

Re: Windows Batch Crop

Post by lionelthomas »

Thank you kindly. I will try that.
lionelthomas
Posts: 6
Joined: 2015-07-03T10:06:03-07:00
Authentication code: 1151

Re: Windows Batch Crop

Post by lionelthomas »

Thank you, that worked famously.
Post Reply