SUMMARY
Q: What is the command that I would use to extract the right-side 52%x100% of an image?
DETAIL
I only use ImageMagick a couple of times a year, so I never get good at it.
Current problem: splitting double-page "spread" images into single pages.
I have received a number of pages from scanned books which are two pages wide.
I want to split them into two pages, left and right.
The binding of the book isn't always in the center, so I want there to
be some overlap. I'll fine-tune the cropping by hand later.
I can successfully extract the left page image using
$ convert spread.jpg -crop 52%x100%+0+0 left.jpg
However, I played around all morning but was unable to
figure out how to grab the "right.jpg" image of the right page.
I have tried various forms of -gravity ... but no luck
I would like to use percentages rather than fixed pixel coordinates
because the double-page-spread images are of slightly different sizes.
Thanks in advance for your assistance.
Michael
split double-page spreads into single-page images
-
- Posts: 5
- Joined: 2010-07-30T14:54:36-07:00
- Authentication code: 8675308
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: split double-page spreads into single-page images
I think you need to specify an Xoffset to get the right side from a crop. I don't think offsets use percents. You could try
convert image -gravity east -crop 48x100%+0+0 result
You can split evenly into two parts at the same time by using -crop 50x100% and leave off the offsets.
convert image -crop 50x100% result
That will produce either two images -0 and -1 or two frames depending upon your output format.
see
http://www.imagemagick.org/Usage/crop/#crop_page
http://www.imagemagick.org/Usage/crop/#crop_gravity
http://www.imagemagick.org/Usage/crop/#crop_percent
http://www.imagemagick.org/Usage/crop/#crop_tile
http://www.imagemagick.org/Usage/crop/#crop_repage
You don't say what version of IM nor platform.
If still having trouble, post a link to your image.
Examples that work for me on IM 6.7.6.9 Q16 Mac OSX Snow Leopard:
convert logo: -gravity west -crop 50x100%+0+0 +repage logo_left.png
convert logo: -gravity east -crop 50x100%+0+0 +repage logo_right.png
convert logo: -crop 50x100% logo_split.png
The repage is needed to remove the virtual canvas, if desired, for png and gif formats. It is not needed for jpg
convert image -gravity east -crop 48x100%+0+0 result
You can split evenly into two parts at the same time by using -crop 50x100% and leave off the offsets.
convert image -crop 50x100% result
That will produce either two images -0 and -1 or two frames depending upon your output format.
see
http://www.imagemagick.org/Usage/crop/#crop_page
http://www.imagemagick.org/Usage/crop/#crop_gravity
http://www.imagemagick.org/Usage/crop/#crop_percent
http://www.imagemagick.org/Usage/crop/#crop_tile
http://www.imagemagick.org/Usage/crop/#crop_repage
You don't say what version of IM nor platform.
If still having trouble, post a link to your image.
Examples that work for me on IM 6.7.6.9 Q16 Mac OSX Snow Leopard:
convert logo: -gravity west -crop 50x100%+0+0 +repage logo_left.png
convert logo: -gravity east -crop 50x100%+0+0 +repage logo_right.png
convert logo: -crop 50x100% logo_split.png
The repage is needed to remove the virtual canvas, if desired, for png and gif formats. It is not needed for jpg
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: split double-page spreads into single-page images
Even image cropping is best done using -crop 2x1@
It can even include or exclude an overlap area in the middle
SeeCropping into roughly Equally Sized Divisions
http://www.imagemagick.org/Usage/crop/#crop_equal
However As your offset percentage is more than 50% you can just use
that will divide teh image into a 52% left and 48% right image
If you want it reversed, use -flop before and again after the crop (to avoid making 3 crop tiles).
It can even include or exclude an overlap area in the middle
SeeCropping into roughly Equally Sized Divisions
http://www.imagemagick.org/Usage/crop/#crop_equal
However As your offset percentage is more than 50% you can just use
Code: Select all
-crop 52x100% +repage
If you want it reversed, use -flop before and again after the crop (to avoid making 3 crop tiles).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 5
- Joined: 2010-07-30T14:54:36-07:00
- Authentication code: 8675308
Re: split double-page spreads into single-page images
Thanks very much for advice on -flop and -crop.
The following worked well:
The following worked well:
Code: Select all
[mth@localhost test1]$ convert twoPageSpread.jpg -crop 52x100% -delete 1 +repage leftPage.jpg
[mth@localhost test1]$ convert twoPageSpread.jpg -flop -crop 52x100% -flop -delete 1 +repage rightPage.jpg
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: split double-page spreads into single-page images
Rather than delete the second image just add a +0+0 to the crop.
As can do it all in the one too using parenthesis, and use gravity instead of flops.
As you are doing a 52% on both sides with overlap. Doing the percentage calculation yourself (the 2% overlap) and using equal-area tile cropping with that overlap (as a negative) will also do the job.
As can do it all in the one too using parenthesis, and use gravity instead of flops.
Code: Select all
convert image \( +clone -crop 52x100%+0+0 +repage -write left_image \) \
-gravity east -crop 52x100%+0+0 +repage -write left_image
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/