LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 10-28-2009, 10:08 AM   #1
jrtayloriv
Member
 
Registered: Jun 2004
Location: Inland NW, US
Distribution: Ubuntu
Posts: 363
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...

Thanks,
Jesse Taylor
 
Old 10-28-2009, 10:24 AM   #2
Lordandmaker
Member
 
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, 02:48 PM   #3
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
They have good documentation here:
http://www.imagemagick.org/script/co...line-tools.php

Here's one way:

Code:
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.
 
  


Reply

Tags
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 03:38 PM
Improving scanned images in linux zack6901 Linux - Software 1 01-11-2007 05:30 PM
xsane trouble - scanned images are red marie@dk Linux - Software 2 11-11-2006 07:36 AM
Splitting dd images Codegen Linux - Software 3 07-23-2006 10:13 AM
Xsane adding blank space to scanned images JamesHall Suse/Novell 3 02-20-2006 10:53 AM


All times are GMT -5. The time now is 12:41 AM.

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