Page 1 of 1

How can I delete a single page of a multiple page image?

Posted: 2010-01-28T15:40:49-07:00
by fasnach
If I identify a single tiff image with this code

Code: Select all

identify aussen_0001b.TIF
I get this result:
aussen_0001b.TIF[0] TIFF 3168x4752 3168x4752+0+0 8-bit TrueColor DirectClass 43.23mb
aussen_0001b.TIF[1] TIFF 168x252 168x252+0+0 8-bit TrueColor DirectClass 43.23mb

There are two tif-images in one tiff-container. How can I delete only the second (aussen_0001b.TIF[1]) with ImageMagick?

Thank you very much for answers

Re: How can I delete a single page of a multiple page image?

Posted: 2010-01-28T16:54:45-07:00
by magick
Try this
  • convert 'aussen_0001b.TIF[0,2-1000]' image.tif

Re: How can I delete a single page of a multiple page image?

Posted: 2010-01-28T19:09:34-07:00
by fmw42
magick wrote:Try this
  • convert 'aussen_0001b.TIF[0,2-1000]' image.tif

This also seems to work for me (with gif with 4 frames)

convert rose: rose: rose: rose: rose4.gif
convert rose4.gif -delete 1 rose4m1.gif

this should delete the second frame (note frame numbers start with 0)

identify rose4.gif
rose4.gif[0] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 14.2KB 0.000u 0:00.000
rose4.gif[1] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 14.2KB 0.000u 0:00.000
rose4.gif[2] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 14.2KB 0.000u 0:00.000
rose4.gif[3] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 14.2KB 0.000u 0:00.000

identify rose4m1.gif
rose4m1.gif[0] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.9KB 0.010u 0:00.010
rose4m1.gif[1] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.9KB 0.000u 0:00.010
rose4m1.gif[2] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.9KB 0.000u 0:00.000

Re: How can I delete a single page of a multiple page image?

Posted: 2010-01-28T23:51:52-07:00
by fasnach
Both solutions work! Thanks a lot!

If I use the first code

Code: Select all

'aussen_0001a.TIF[0,2-1000]' newSingle.TIF
now

Code: Select all

identify newSingle.TIF
the result looks like:
newSingle.TIF TIFF 3168x4752 3168x4752+0+0 8-bit TrueColor DirectClass 43.11mb 0.300u 0:02

if I use the second code

Code: Select all

convert aussen_0001a.TIF -delete 1 newSingle2.tif
now

Code: Select all

identify newSingle2.TIF
the result looks like:
newSingle2.tif TIFF 3168x4752 3168x4752+0+0 8-bit TrueColor DirectClass 43.11mb

But I don't understand by the first the code in the square bracket

Code: Select all

... [0,2-1000]

Re: How can I delete a single page of a multiple page image?

Posted: 2010-01-29T10:43:29-07:00
by fmw42
... [0,2-1000]
This says keep only frames 0 and frames 2 to 1000 (if they exist). So it is deleting frame 1 (which is the second frame as frame numbers start at 0)

I am not sure your tiff is multi-frame. What do you get from

identify aussen_0001a.TIF

if it does not list more than aussen_0001a.TIF then you only have one frame/page. It must list all the frames starting at [0] as in my gif example.

Re: How can I delete a single page of a multiple page image?

Posted: 2010-01-29T11:55:30-07:00
by fasnach
I photograph with Canon 50D. The image format is a canon proprietary format. To transform this format to tiff I use the canon software Digital Photo Professional (DPP). This means that the transforming process automatically produce two tiffs in one tiff container. The image and its thumb. (I found no way in DPP to make only the image but not the thumb).

If I identify with imageMagick one of this canon produced tiffs (e.g. aussen_0001a.TIF) I get this informations:

aussen_0001a.TIF[0] TIFF 3168x4752 3168x4752+0+0 16-bit TrueColor DirectClass 86.31mb 0.730u 0:03
aussen_0001a.TIF[1] TIFF 168x252 168x252+0+0 8-bit TrueColor DirectClass 86.31mb
identify: aussen_0001a.TIF: unknown field with tag 40961 (0xa001) encountered. `TIFFReadCustomDirectory'.

Then I delete the second tif aussen_0001a.TIF[1] with this code

Code: Select all

convert 'aussen_0001a.TIF[0,2-1000]' new_aussen_0001a.TIF
I get this note:
  • convert: aussen_0001a.TIF: unknown field with tag 40961 (0xa001) encountered. `TIFFReadCustomDirectory'.
It seems like an error but the new image (new_ausse_0001a.TIF) is produced.

After identifying

Code: Select all

identify new_aussen_0001a.TIF
this message appears:
new_aussen_0001a.TIF TIFF 3168x4752 3168x4752+0+0 16-bit TrueColor DirectClass 86.18mb

So I think there are indeed frames. But in my case (there are only two frames) I can write the follow code:

Code: Select all

convert aussen_0001a.TIF[0] image.TIF
But one question: what does the message convert: aussen_0001a.TIF: unknown field with tag 40961 (0xa001) encountered. `TIFFReadCustomDirectory'. mean?

Re: How can I delete a single page of a multiple page image?

Posted: 2010-01-29T15:52:30-07:00
by fmw42
But one question: what does the message convert: aussen_0001a.TIF: unknown field with tag 40961 (0xa001) encountered. `TIFFReadCustomDirectory'. mean?
It is just a warning that there is some field in the tiff file that IM does not recognize and can be ignored.

Looks like you have successfully deleted the thumbnail and are left with only the main image.