Page 1 of 1

Split an image in half, save as two.

Posted: 2013-09-13T16:00:16-07:00
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.

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

Posted: 2013-09-13T17:04:20-07:00
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

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

Posted: 2013-09-13T18:44:51-07:00
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