I am trying to crop a single page of a multipage tif in a single operation.
Source.tif is a 15 page tif file. I want to crop page 2 to 1700 X 1300 @ 250,50.
I can get it to work using 3 separate commmands;
convert Source.tif[1] -crop 1700X1300+250+50 +repage croppedPage.tif
convert Source.tif -delete 1 deletedPage.tif
convert deletedPage.tif croppedPage.tif -insert 1 newSource.tif
Although this works, it is slow on large multipage files. So, I want to do it in one command.
I tried:
convert Source.tif ( -delete 1 ) Source.tif[1] -crop 1700X1300+250+50 +repage -insert 1 newSource.tif
and:
convert Source.tif ( -delete 1 ) Source.tif[1] ( -crop 1700X1300+250+50 +repage ) -insert 1 newSource.tif
but that crops every page.
I tried:
convert Source.tif ( -delete 1 ) ( Source.tif[1] -crop 1700X1300+250+50 +repage ) -insert 1 newSource.tif
but that just moves the last page to the first.
Any ideas?
Gerald
crop page in multipage tif
-
- Posts: 5
- Joined: 2012-02-15T13:03:32-07:00
- Authentication code: 8675308
- Contact:
crop page in multipage tif
Gerald McCartney
CGI Technologies and Solutions
CGI Technologies and Solutions
-
- Posts: 5
- Joined: 2012-02-15T13:03:32-07:00
- Authentication code: 8675308
- Contact:
Re: crop page in multipage tif
I got it to work using:
convert Source.tif ( Source.tif[1] -crop 1700X1300+250+50 +repage ) -insert 1 ( -delete 2 ) newSource.tif
note: incremented the delete page number since I inserted in front of it...
No idea why reversing the order of operations worked, but it did...
Gerald
convert Source.tif ( Source.tif[1] -crop 1700X1300+250+50 +repage ) -insert 1 ( -delete 2 ) newSource.tif
note: incremented the delete page number since I inserted in front of it...
No idea why reversing the order of operations worked, but it did...
Gerald
Gerald McCartney
CGI Technologies and Solutions
CGI Technologies and Solutions
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: crop page in multipage tif
I don't believe that you need the parens around the -delete 2
You don't have to read the file twice. All the frames of the input image are counted separately.
So this should work to copy only frame 1 to be cropped.
convert Source.tif ( -clone 1 -crop 1700X1300+250+50 +repage ) -insert 1 -delete 2 newSource.tif
You don't have to read the file twice. All the frames of the input image are counted separately.
So this should work to copy only frame 1 to be cropped.
convert Source.tif ( -clone 1 -crop 1700X1300+250+50 +repage ) -insert 1 -delete 2 newSource.tif
-
- Posts: 5
- Joined: 2012-02-15T13:03:32-07:00
- Authentication code: 8675308
- Contact:
Re: crop page in multipage tif
The -clone operator worked perfectly.
Thank you.
Thank you.
Gerald McCartney
CGI Technologies and Solutions
CGI Technologies and Solutions
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: crop page in multipage tif
The better (nicer) way is this...
convert Source.tif ( -clone 1 -crop 1700X1300+250+50 +repage ) -swap 1 +delete newSource.tif
More about this in IM Exmaples, Basics, Combining Image Sequence Operations
http://www.imagemagick.org/Usage/basics/#seq_combine
convert Source.tif ( -clone 1 -crop 1700X1300+250+50 +repage ) -swap 1 +delete newSource.tif
More about this in IM Exmaples, Basics, Combining Image Sequence Operations
http://www.imagemagick.org/Usage/basics/#seq_combine
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/