Split an image in half, save as two.

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
Scud
Posts: 3
Joined: 2013-09-13T15:50:58-07:00
Authentication code: 6789

Split an image in half, save as two.

Post by Scud »

I have a bunch of manga pages, they're all the same size, I need them split in half vertically down the middle and the result saved as two individual images.

I could do the automation in Bash, just need some help with the ImageMagick part, I would really appreciate it. Here's an example of an image I'm trying to converet: http://s15.postimg.org/ae5srlip5/178.jpg

Nevermind, I got it,

Code: Select all

convert ./image.png -crop 50%x100% out.png
Don't know why I was having so much trouble finding that. Also put it in a bash script and it works perfectly: http://pastebin.com/ETvcEnWH

There is some images that don't need to be split and that kind of sucks, I'm trying to think of a way where it can check the resolution of an image and if resolution of image is < than X horizantal resolution it gets exempted from the command and left alone. That would be very easy itself I just need a way to return the exact resolution of an image, back to google.

Sorry if this just became me ranting to myself. I was going to delete the thread but I figured sometimes ancient threads always show up on google and help people out.
Last edited by Scud on 2013-09-13T20:51:01-07:00, edited 2 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Split an image in half, save as two.

Post by fmw42 »

what do you mean by "resolution"? Is that the number of pixels or the dpi?

See string formats %x and %y for dpi. If just the image width or height then %w or %h

ww=`identify -format "%w" yourimage`

or

ww=`convert yourimage -format "%w" info:`

http://www.imagemagick.org/script/escape.php
Scud
Posts: 3
Joined: 2013-09-13T15:50:58-07:00
Authentication code: 6789

Re: Split an image in half, save as two.

Post by Scud »

fmw42 wrote:what do you mean by "resolution"? Is that the number of pixels or the dpi?

See string formats %x and %y for dpi. If just the image width or height then %w or %h

ww=`identify -format "%w" yourimage`

or

ww=`convert yourimage -format "%w" info:`

http://www.imagemagick.org/script/escape.php
Exactly what I was looking for, excellent, thank you. Just finished up the script with the ability to only modify images above a certain horizontal resolution and it works great.

http://pastebin.com/acqNsdUw
Post Reply