Convert delete layer from TIFF, save as JPEG

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
cmcfarling
Posts: 14
Joined: 2003-12-23T12:39:53-07:00

Convert delete layer from TIFF, save as JPEG

Post by cmcfarling »

I'm trying to remove one layer from a TIFF that contains two layers and then save as a JPEG file.

I've tried two different commands with no luck:

Code: Select all

convert c:\Temp\TIFFLZW.tif'[0]' c:\Temp\test.jpg
This results in the following output:

Magick: unable to open image `c:\Temp\TIFFLZW.tif'[0]'': No such file or directory @ error/blob.c/OpenBlob/2514.
Magick: no decode delegate for this image format `c:\Temp\TIFFLZW.tif'[0]'' @ error/constitute.c/ReadImage/532.
Magick: missing an image filename `c:\Temp\test.jpg' @ error/convert.c/ConvertImageCommand/2970.

Code: Select all

convert c:\Temp\TIFFLZW.tif -delete 0 c:\Temp\test.jpg
This results in the following output:

Magick: c:\Temp\TIFFLZW.tif: wrong data type 7 for "RichTIFFIPTC"; tag ignored.
`TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/704.
Magick: c:\Temp\TIFFLZW.tif: unknown field with tag 37724 (0x935c) encountered.
`TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/704.
Magick: missing an image filename `c:\Temp\test.jpg' @ error/convert.c/ConvertImageCommand/2970.



Here is the TIFF file:
http://www.50amp.com/im/TIFFLZW.tif

ImageMagick version is 6.6.3
TIFF Delegate is enabled
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert delete layer from TIFF, save as JPEG

Post by fmw42 »

IM only sees one layer via identify -verbose. But it gets copied just fine to the jpg on my IM 6.6.9.5 Q16 Mac OSX Tiger. The rest are warnings that seem to be ignored.
cmcfarling
Posts: 14
Joined: 2003-12-23T12:39:53-07:00

Re: Convert delete layer from TIFF, save as JPEG

Post by cmcfarling »

What command did you use?

Either of the commands mentioned in the original post produce the same error with IM 6.6.9 Q8 on Windows.

Did your converted file have the text "WATERMARK" included in it? The ultimate goal is to strip the layer with the "WATERMARK" text in it, leaving just the image layer.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert delete layer from TIFF, save as JPEG

Post by fmw42 »

cmcfarling wrote:What command did you use?

Either of the commands mentioned in the original post produce the same error with IM 6.6.9 Q8 on Windows.

Did your converted file have the text "WATERMARK" included in it? The ultimate goal is to strip the layer with the "WATERMARK" text in it, leaving just the image layer.

IM only sees one frame -- it is the watermark flattened onto the background. So the result of my processing looks exactly like the only frame IM sees and ends with the red WATERMARK on it.

convert TIFFLZW.tif TIFFLZW.jpg

IM on Mac OSX Tiger IM 6.6.9.5 Q16

You can see there is only one frame using

identify TIFFLZW.tif

TIFFLZW.tif TIFF 648x486 648x486+0+0 8-bit DirectClass 1.617MB 0.120u 0:00.129
identify: TIFFLZW.tif: wrong data type 7 for "RichTIFFIPTC"; tag ignored. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/706.
identify: TIFFLZW.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/706.

The warnings are ignored.
cmcfarling
Posts: 14
Joined: 2003-12-23T12:39:53-07:00

Re: Convert delete layer from TIFF, save as JPEG

Post by cmcfarling »

The file was created in Photoshop (CS4). When opened in Photoshop there are two layers present. Any ideas why why IM doesn't see two layers? Is it known if IM typically recognizes layers in Photoshop generated TIFFs?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert delete layer from TIFF, save as JPEG

Post by fmw42 »

cmcfarling wrote:The file was created in Photoshop (CS4). When opened in Photoshop there are two layers present. Any ideas why why IM doesn't see two layers? Is it known if IM typically recognizes layers in Photoshop generated TIFFs?

I am not the expert on TIFF and PSD files, but from my experience, IM generally sees multiple layers, with the first the flattened layer. It may have to do with the warnings you are getting. Also there may still be some bugs, I believe, in handling of background vs alpha transparency (as it can deal with only one or the other) and other issues with layers in IM PSD and TIFF.

I opened your file in my PS CS (old) and it shows two layers, one is the background transparency with the red WATERMARK and the other is the image. But there is no flattened layer as is typical with PSD and TIFF, I believe. IM apparently has flattened the two into one layer. Perhaps you can try writing out your tiff in such a way as to create the flattened layer and we can try again.

Otherwise, you might need to submit a bug report about this on the Bugs forum.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert delete layer from TIFF, save as JPEG

Post by fmw42 »

I have been able to extract your layer without the watermark by going into PS and swapping the order of the two layers, then saving the file as tiff again. Then in IM

convert TIFFLZW_swappedlayers.tif[0] TIFFLZW_swappedlayers.png

only shows the background and not the WATERMARK layer.
LinuxPope
Posts: 11
Joined: 2012-01-14T07:27:34-07:00
Authentication code: 8675308

Re: Convert delete layer from TIFF, save as JPEG

Post by LinuxPope »

Sorry to open this old thread again, but the bug still exists, I can't extract layers from TIFF files generated by Photoshop CS. Same problem as the original poster.

Looking at older threads, it appears like this was working in 2008 for many people by simply doing:

Code: Select all

convert mulitple.tif layer%d.tif
Apparently this no longer works.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert delete layer from TIFF, save as JPEG

Post by fmw42 »

can you post a link to your tif file.
LinuxPope
Posts: 11
Joined: 2012-01-14T07:27:34-07:00
Authentication code: 8675308

Re: Convert delete layer from TIFF, save as JPEG

Post by LinuxPope »

no I'm sorry, it is work related. These are tiff images given to us from various web designers, so they are copyrighted.

I asked and they told me that they work on PSD files but save them as multi-layered tiff files when they need to send them to web developers. Since I don't use windows, I can't re-recreate any samples. Sorry.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert delete layer from TIFF, save as JPEG

Post by fmw42 »

LinuxPope wrote:no I'm sorry, it is work related. These are tiff images given to us from various web designers, so they are copyrighted.

I asked and they told me that they work on PSD files but save them as multi-layered tiff files when they need to send them to web developers. Since I don't use windows, I can't re-recreate any samples. Sorry.

Can you provide the information from:

identify -verbose image.tiff
LinuxPope
Posts: 11
Joined: 2012-01-14T07:27:34-07:00
Authentication code: 8675308

Re: Convert delete layer from TIFF, save as JPEG

Post by LinuxPope »

Sure, here you go.

I hope my old-ish version of imagemagick isn't a problem, if it is then let me know and I'll run the same command on a newer version.

Code: Select all

Image: homepage.tif
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 1895x1078+0+0
  Resolution: 72x72
  Print size: 26.3194x14.9722
  Units: PixelsPerInch
  Type: TrueColor
  Base type: TrueColor
  Endianess: MSB
  Colorspace: RGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    red:
      min: 0 (0)
      max: 255 (1)
      mean: 152.136 (0.596612)
      standard deviation: 101.956 (0.399828)
      kurtosis: -1.624
      skewness: -0.475824
    green:
      min: 0 (0)
      max: 255 (1)
      mean: 163.625 (0.641668)
      standard deviation: 83.872 (0.32891)
      kurtosis: -1.56343
      skewness: -0.455362
    blue:
      min: 0 (0)
      max: 255 (1)
      mean: 164.608 (0.645522)
      standard deviation: 63.6958 (0.249787)
      kurtosis: -0.583204
      skewness: -0.643916
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 120.092 (0.470951)
      standard deviation: 101.011 (0.39612)
      kurtosis: -1.73361
      skewness: -0.00192352
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Compose: Over
  Page geometry: 1895x1078+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: None
  Orientation: TopLeft
  Properties:
    date:create: 2012-05-24T16:00:45+03:00
    date:modify: 2012-05-04T19:21:46+03:00
    dc:format: image/tiff
    exif:ColorSpace: 1
    exif:NativeDigest: 36864,40960,40961,37121,37122,40962,40963,37510,40964,36867,36868,33434,33437,34850,34852,34855,34856,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37396,41483,41484,41486,41487,41488,41492,41493,41495,41728,41729,41730,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,42016,0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,23,24,25,26,27,28,30;105DB658C3B27F3DF882430D44E2F00A
    exif:PixelXDimension: 1895
    exif:PixelYDimension: 1078
    photoshop:ColorMode: 3
    photoshop:ICCProfile: sRGB IEC61966-2.1
    signature: fb48d0b091dbd6c9a6db02b2d20699e6ddaa60b610a8936c32eadf3cea7c5f92
    stRef:documentID: xmp.did:E99D53532482E111BB85B428E4A30BF5
    stRef:instanceID: xmp.iid:615B8E7F0396E111BE9389167E07F845
    stRef:originalDocumentID: xmp.did:E99D53532482E111BB85B428E4A30BF5
    tiff:Compression: 1
    tiff:ImageLength: 1078
    tiff:ImageWidth: 1895
    tiff:NativeDigest: 256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;8D0E156127727A4BF8F01E004901D3DC
    tiff:photometric: RGB
    tiff:PhotometricInterpretation: 2
    tiff:PlanarConfiguration: 1
    tiff:rows-per-strip: 1
    tiff:SamplesPerPixel: 3
    tiff:software: Adobe Photoshop CS4 Windows
    tiff:timestamp: 2012:05:04 19:21:41
    xmp:CreateDate: 2012-04-09T17:45:52+03:00
    xmp:CreatorTool: Adobe Photoshop CS4 Windows
    xmp:MetadataDate: 2012-05-04T19:21:41+03:00
    xmp:ModifyDate: 2012-05-04T19:21:41+03:00
    xmpMM:DocumentID: xmp.did:E99D53532482E111BB85B428E4A30BF5
    xmpMM:InstanceID: xmp.iid:625B8E7F0396E111BE9389167E07F845
    xmpMM:OriginalDocumentID: xmp.did:E99D53532482E111BB85B428E4A30BF5
  Profiles:
    Profile-8bim: 11394 bytes
    Profile-icc: 3144 bytes
      IEC 61966-2.1 Default RGB colour space - sRGB
    Profile-iptc: 7 bytes
      unknown[2,0]: 
    Profile-tiff:37724: 29133344 bytes
    Profile-xmp: 117912 bytes
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 35.39MB
  Number pixels: 2.043MB
  Pixels per second: 9.728MB
  User time: 0.160u
  Elapsed time: 0:01.210
  Version: ImageMagick 6.5.8-10 2010-12-17 Q16 http://www.imagemagick.org
identify: homepage_v3.1.tif: wrong data type 7 for "RichTIFFIPTC"; tag ignored. `TIFFReadDirectory' @ tiff.c/TIFFWarnings/703.
identify: homepage_v3.1.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory' @ tiff.c/TIFFWarnings/703.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert delete layer from TIFF, save as JPEG

Post by fmw42 »

This tiff file appears to only have one layer.

type

identify image.tiff

what do you get

If you do not see more than one line listed, then it indeed only has one layer (probably the flattened result of all the psd layers). So perhaps your user has accidentally flattened the psd when saving as tiff.


Here is a quick test to show you how multiple layers should appear.

convert rose: rose: rose: rose.tiff
identify rose.tiff
rose.tiff[0] TIFF 70x46 70x46+0+0 8-bit DirectClass 30.1KB 0.000u 0:00.000
rose.tiff[1] TIFF 70x46 70x46+0+0 8-bit DirectClass 30.1KB 0.000u 0:00.000
rose.tiff[2] TIFF 70x46 70x46+0+0 8-bit DirectClass 30.1KB 0.000u 0:00.000
LinuxPope
Posts: 11
Joined: 2012-01-14T07:27:34-07:00
Authentication code: 8675308

Re: Convert delete layer from TIFF, save as JPEG

Post by LinuxPope »

I confirmed with the designer, the file has layers (which also explains why it is 35MB!)

I only see some errors:

Code: Select all

homepage.tif TIFF 1895x1078 1895x1078+0+0 8-bit DirectClass 35.39MB 0.140u 0:00.139
identify: homepage.tif: wrong data type 7 for "RichTIFFIPTC"; tag ignored. `TIFFReadDirectory' @ tiff.c/TIFFWarnings/703.
identify: homepage.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory' @ tiff.c/TIFFWarnings/703.
I also loaded the file in GIMP and re-saved it without compression and it came out as 6MB (gimp doesn't support layers either, so it can only see a flat image). Even at 1895x1078 I don't see how the file could be 35MB without layers, and the designer has no reason to trick me :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert delete layer from TIFF, save as JPEG

Post by fmw42 »

Those messages are warning not errors. Some tiff fields IM does not read and gives a warning.

I cannot help much further without a file. Can your client make a bogus one that has this problem.

Both IM and GIMP can read layers from TIFF. So something is wrong if neither shows but one layer. Perhaps the layers are not normal layers, but effects layers. Things of that nature neither IM nor I suppose GIMP will handle.


Can you make a screen snap from within Photoshop to show the layers window. The images there should be so small as not to be of much use to anyone. Or make the screen snap and paint the images out so that we can only see the types of layers and how many.


Look at the IM verbose statistics posted earlier. You will see toward the end

Profile-tiff:37724: 29133344 bytes

This means that there is some tiff profile that by itself is 29 Mbytes. So it is conceivable that the file size has nothing to do with multiple layers or those are special layers that nothing but PS will read.
Post Reply