I am moving pages from one tif to another.
Moving one page works great. This command inserts page 2 from file2.tif into file1.tif as page 2 of the result.tif:
convert file1.tif file2.tif[1] -insert 1 result.tif
But if I try to move a range of pages, onyl the first page goes to the correct destination. The rest go to the end of the file.
This command inserts page 2 from file2.tif into file1.tif as page 2, but then adds page 3 from file2.tif as the last page of the result.tif:
convert file1.tif file2.tif[1-2] -insert 1 result.tif
Does the -insert operator process ranges differently?
Gerald
moving pages from one multipage tiff to another
-
- Posts: 5
- Joined: 2012-02-15T13:03:32-07:00
- Authentication code: 8675308
- Contact:
moving pages from one multipage tiff to another
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: moving pages from one multipage tiff to another
see http://www.imagemagick.org/Usage/basics/#insert
I believe that insert only works with one image at a time.
"The "-insert" operation is sort of the opposite of "-delete". It will take the last image in the current image sequence and insert so that it is positioned at the given index."
So you will have to do multiple -insert in the same command line.
I believe that insert only works with one image at a time.
"The "-insert" operation is sort of the opposite of "-delete". It will take the last image in the current image sequence and insert so that it is positioned at the given index."
So you will have to do multiple -insert in the same command line.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: moving pages from one multipage tiff to another
As an alternative try this...
yes it reads the first image twice, but it will do the job.
Another alternative with just one read.
Note that the actual write is in the middle of the command, not at the end.
Looks like we need something to swap between the current image list and the 'pushed' image list
to really solve this problem nicely.
Third solution, using MPR: which is a image list saver
See IM Examples, File Handling, MPR
http://www.imagemagick.org/Usage/files/#mpr
Code: Select all
convert 'file1.tif[0]' 'file2.tif[1-2]' 'file1.tif[1-]' result.tif
Another alternative with just one read.
Code: Select all
convert file1.tif \( -clone 0 file2.tif -clone 1--1 -write result.tif \) null:
Looks like we need something to swap between the current image list and the 'pushed' image list
to really solve this problem nicely.
Third solution, using MPR: which is a image list saver
Code: Select all
convert file1.tif -write MPR:images -delete 0--1 \
'MPR:images[0]' file2.tif MPR:images[1--1]' result.tif
http://www.imagemagick.org/Usage/files/#mpr
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 5
- Joined: 2012-02-15T13:03:32-07:00
- Authentication code: 8675308
- Contact:
Re: moving pages from one multipage tiff to another
hmmm, so if the users asks to move pages 1,3 and 5 from file 1 to file2 after page 3 could I use:
convert file1.tif -write MPR:file1 +delete file2.tif -write MPR:file2 +delete \
MPR:file2[0-2] MPR:file1[0] MPR:file1[2] MPR:file1[4] MPR:file1[3--1] result.tif
I will have to try that...
Gerald
convert file1.tif -write MPR:file1 +delete file2.tif -write MPR:file2 +delete \
MPR:file2[0-2] MPR:file1[0] MPR:file1[2] MPR:file1[4] MPR:file1[3--1] result.tif
I will have to try that...
Gerald
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: moving pages from one multipage tiff to another
Yeap. The mpr: image save memory is very efficient as it clones the image list.
That means image data is not copied only refered to, until you actually modify images, which you are not doing.
That means image data is not copied only refered to, until you actually modify images, which you are not doing.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/