Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Desktop
User Name
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.


  Search this Thread
Old 10-28-2009, 11:08 AM   #1
Registered: Jun 2004
Location: Inland NW, US
Distribution: Ubuntu
Posts: 365
Blog Entries: 1

Rep: Reputation: 44
Splitting scanned images vertically, halfway across width of image

I've got a batch of about 150 JPEG images that are named 0010.jpg, 0012.jpg, 0014.jpg ...

I am trying to figure out a command that will take each of these images and say "Go 50% across the width of the image from the left edge, and split it down the middle (from top to bottom). This will create two seperate jpg files, one for the left half, one for the right half. If the original (unsplit) image is named 0150.jpg, then the left half would be named 0150.jpg (same as original), and the right image would be named 0151.jpg".

How do I do this? I know I can do this with GIMP by manually editing each image, but that will take many hours to do. I am guessing that there is probably an imagemagick command that I could use to do this very quickly...

Jesse Taylor
Old 10-28-2009, 11:24 AM   #2
Registered: Sep 2005
Location: London, UK
Distribution: Debian
Posts: 258

Rep: Reputation: 38
Look at "identify" to get the height and width of the image in px, then use convert to crop it?

I'm not familiar enough with imagemagick to say exactly how you'd do it, but I'd say you're looking at a script rather than a command.
Old 10-28-2009, 03:48 PM   #3
LQ Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
They have good documentation here:

Here's one way:

convert -crop $(identify input.jpg | awk '{ i=index($3,"x"); print int(substr($3,1,i-1)/2)substr($3,i) }') input.jpg output.jpg
Then you can use 'mv' to fix the names.


imagemagick, images, split

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I print a scanned image? PaulFXH Linux - Software 2 06-10-2009 04:38 PM
Improving scanned images in linux zack6901 Linux - Software 1 01-11-2007 06:30 PM
xsane trouble - scanned images are red marie@dk Linux - Software 2 11-11-2006 08:36 AM
Splitting dd images Codegen Linux - Software 3 07-23-2006 11:13 AM
Xsane adding blank space to scanned images JamesHall SUSE / openSUSE 3 02-20-2006 11:53 AM > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 09:33 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration