Resize, crop, and splice multiple image files

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
ibacbea
Posts: 3
Joined: 2016-09-29T11:04:00-07:00
Authentication code: 1151

Resize, crop, and splice multiple image files

Post by ibacbea »

I have 10 images in the same folder:

01.jpg
02.jpg
...
10.jpg

I need a batch file to do the following:

1) Resize all to 1800(w)x1200(h)px.
2) Split all images horizontally (1800x600px) to create a top and bottom half of each image (top01.jpg, bot01.jpg...,top10.jpg, bot10.jpg).
3) Merge halves to create 10 new 1800x1200px images with the following combinations: top01/bot02, top02/bot03,..., top09/bot10, top10/bot01.
4) New files should be named new01, new02, etc. to the same origin folder.

Step 2 doesn't actually need to save the halves as long as the new images in Step 4 have the desired result.

Thanks in advance.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Resize, crop, and splice multiple image files

Post by Bonzo »

What have you tried?

Try doing one image a step at a time and when you have done that you can then move onto the multiple images.

This forum is to help people with their code not to write their code for them.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resize, crop, and splice multiple image files

Post by fmw42 »

ibacbea
Posts: 3
Joined: 2016-09-29T11:04:00-07:00
Authentication code: 1151

Re: Resize, crop, and splice multiple image files

Post by ibacbea »

magick "C:\Program Files\ImageMagick\images\01.jpg" -crop 1800x600 "C:\Program Files\ImageMagick\images\half01.jpg"
magick "C:\Program Files\ImageMagick\images\02.jpg" -crop 1800x600 "C:\Program Files\ImageMagick\images\half02.jpg"
magick "C:\Program Files\ImageMagick\images\03.jpg" -crop 1800x600 "C:\Program Files\ImageMagick\images\half03.jpg"
magick "C:\Program Files\ImageMagick\images\04.jpg" -crop 1800x600 "C:\Program Files\ImageMagick\images\half04.jpg"
magick "C:\Program Files\ImageMagick\images\05.jpg" -crop 1800x600 "C:\Program Files\ImageMagick\images\half05.jpg"
magick "C:\Program Files\ImageMagick\images\06.jpg" -crop 1800x600 "C:\Program Files\ImageMagick\images\half06.jpg"
magick "C:\Program Files\ImageMagick\images\07.jpg" -crop 1800x600 "C:\Program Files\ImageMagick\images\half07.jpg"
magick "C:\Program Files\ImageMagick\images\08.jpg" -crop 1800x600 "C:\Program Files\ImageMagick\images\half08.jpg"
magick "C:\Program Files\ImageMagick\images\09.jpg" -crop 1800x600 "C:\Program Files\ImageMagick\images\half09.jpg"
magick "C:\Program Files\ImageMagick\images\10.jpg" -crop 1800x600 "C:\Program Files\ImageMagick\images\half10.jpg"
magick "C:\Program Files\ImageMagick\images\half01-0.jpg" "C:\Program Files\ImageMagick\images\half02-1.jpg" -append "C:\Program Files\ImageMagick\images\new01.jpg"
magick "C:\Program Files\ImageMagick\images\half02-0.jpg" "C:\Program Files\ImageMagick\images\half03-1.jpg" -append "C:\Program Files\ImageMagick\images\new02.jpg"
magick "C:\Program Files\ImageMagick\images\half03-0.jpg" "C:\Program Files\ImageMagick\images\half04-1.jpg" -append "C:\Program Files\ImageMagick\images\new03.jpg"
magick "C:\Program Files\ImageMagick\images\half04-0.jpg" "C:\Program Files\ImageMagick\images\half05-1.jpg" -append "C:\Program Files\ImageMagick\images\new04.jpg"
magick "C:\Program Files\ImageMagick\images\half05-0.jpg" "C:\Program Files\ImageMagick\images\half06-1.jpg" -append "C:\Program Files\ImageMagick\images\new05.jpg"
magick "C:\Program Files\ImageMagick\images\half06-0.jpg" "C:\Program Files\ImageMagick\images\half07-1.jpg" -append "C:\Program Files\ImageMagick\images\new06.jpg"
magick "C:\Program Files\ImageMagick\images\half07-0.jpg" "C:\Program Files\ImageMagick\images\half08-1.jpg" -append "C:\Program Files\ImageMagick\images\new07.jpg"
magick "C:\Program Files\ImageMagick\images\half08-0.jpg" "C:\Program Files\ImageMagick\images\half09-1.jpg" -append "C:\Program Files\ImageMagick\images\new08.jpg"
magick "C:\Program Files\ImageMagick\images\half09-0.jpg" "C:\Program Files\ImageMagick\images\half10-1.jpg" -append "C:\Program Files\ImageMagick\images\new09.jpg"
magick "C:\Program Files\ImageMagick\images\half10-0.jpg" "C:\Program Files\ImageMagick\images\half01-1.jpg" -append "C:\Program Files\ImageMagick\images\new10.jpg"

Any way to avoid saving the "half" images and skip right to the final result?
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Resize, crop, and splice multiple image files

Post by GeeMack »

ibacbea wrote:Any way to avoid saving the "half" images and skip right to the final result?
Open a command prompt, navigate into the directory where those images are, make sure there aren't any other JPG images in that directory, ones you don't want included in the processing, and try this...

Code: Select all

magick *.jpg -resize 1800x1200! -roll +0+600 -append -roll +0-600 -crop 1800x1200 -scene 1 new%02d.jpg
Post Reply