Watermarking TIF files gives distorted outputs

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?".
Post Reply
aamir4774@gmail.com
Posts: 15
Joined: 2019-03-05T22:47:03-07:00
Authentication code: 1152

Watermarking TIF files gives distorted outputs

Post by aamir4774@gmail.com »

I'm trying to watermark .tif files using the below command, for some of the tif files it works fine but for some it an distorted output with a message on console as follows:
wrong data type 7 for "RichTIFFIPTC"; tag ignored. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/918.

The commad used for watermarking the files is:

Code: Select all

magick "<input.tif>" -set option:wd "%[fx:0.6*w]" \( -background transparent -size "%[wd]x" -stroke "#000b" -fill "#000a" label:"Copyright" -blur 3x3 -stroke none  -fill "#ffff" label:"Copyright" -flatten \) -gravity center -compose dissolve -define compose:args=50 -composite -quality 50 -geometry +0+25 -compose over -composite "<output.tif>"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Watermarking TIF files gives distorted outputs

Post by snibgo »

... for some it an distorted output ...
Distorted how? Please link to sample input and output.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Watermarking TIF files gives distorted outputs

Post by fmw42 »

The message is a warning and should not affect the output. You can avoid seeing warnings by adding -quiet right after magick
aamir4774@gmail.com
Posts: 15
Joined: 2019-03-05T22:47:03-07:00
Authentication code: 1152

Re: Watermarking TIF files gives distorted outputs

Post by aamir4774@gmail.com »

Yes, it does watermark the output image file, but the watermark doesn't appear in the centre as it should and also the output image looks kind of distorted. Is this the command that needs to be rectified?

Sorry for confidential reasons I cannot share the image file, but the common observation is that file size where this issue is encountered are larger in size (more than 100 mb)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Watermarking TIF files gives distorted outputs

Post by fmw42 »

You have two composites in a row at the end (-compose dissolve and -compose over), but after the first composite there is no second image to composite.

Also you may have a virtual canvas in your input tif. So you may need to add +repage after reading it.

Also be sure you only have one layer in your tif file. If it has transparency, then imagemagick will see to layers. You can try putting [0] at the end of the input tif to read only the first layer.

If that does not help. The post the information from identify -verbose on your tif input.
aamir4774@gmail.com
Posts: 15
Joined: 2019-03-05T22:47:03-07:00
Authentication code: 1152

Re: Watermarking TIF files gives distorted outputs

Post by aamir4774@gmail.com »

I tried simplifying the command as below but the output is still the same

Code: Select all

magick input.tif-set option:wd "%[fx:0.6*w]" \( -background none -size "%[wd]x" -fill white label:"Copyright" -rotate "315" \) -gravity center -geometry +0+25 -compose over -composite output.tif
Below is the verbose information of one of those files.

Code: Select all

Image: inputimages/errorfile1.tif
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 4096x2314+0+0
  Resolution: 72x72
  Print size: 56.8889x32.1389
  Units: PixelsPerInch
  Type: ColorSeparationAlpha
  Endianess: LSB
  Colorspace: CMYK
  Depth: 16-bit
  Channel depth:
    Cyan: 16-bit
    Magenta: 16-bit
    Yellow: 16-bit
    Black: 16-bit
    Alpha: 16-bit
  Channel statistics:
    Pixels: 9478144
    Cyan:
      min: 0 (0)
      max: 65535 (1)
      mean: 4607.25 (0.0703021)
      standard deviation: 14051.2 (0.214408)
      kurtosis: 5.80062
      skewness: 2.77118
      entropy: 0.109805
    Magenta:
      min: 0 (0)
      max: 65535 (1)
      mean: 4403.19 (0.0671883)
      standard deviation: 13308.1 (0.203068)
      kurtosis: 5.36888
      skewness: 2.70578
      entropy: 0.102811
    Yellow:
      min: 0 (0)
      max: 65535 (1)
      mean: 4176.58 (0.0637305)
      standard deviation: 12655.5 (0.19311)
      kurtosis: 5.50915
      skewness: 2.72571
      entropy: 0.112613
    Black:
      min: 0 (0)
      max: 65535 (1)
      mean: 4923.29 (0.0751246)
      standard deviation: 15253.1 (0.232747)
      kurtosis: 6.14946
      skewness: 2.83409
      entropy: 0.118214
    Alpha:
      min: 0 (0)
      max: 65535 (1)
      mean: 6378.67 (0.0973322)
      standard deviation: 19397.1 (0.295981)
      kurtosis: 5.38865
      skewness: 2.71713
      entropy: 0.0418802
  Image statistics:
    Overall:
      min: 0 (0)
      max: 65535 (1)
      mean: 4897.79 (0.0747355)
      standard deviation: 15123.5 (0.23077)
      kurtosis: 6.9149
      skewness: 2.91338
      entropy: 0.0970645
  Total ink density:    400%
  Alpha: cmyka(0,0,0,0,0)   #00000000000000000000
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Alpha color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 4096x2314+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 0 of 2
  Compression: None
  Orientation: TopLeft
  Properties:
    date:create: 2019-04-23T23:53:21-07:00
    date:modify: 2019-04-23T23:42:35-07:00
    dc:format: image/tiff
    exif:ColorSpace: 65535
    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;CA0835B42D901D360F1C3EF77D94001D
    exif:PixelXDimension: 4096
    exif:PixelYDimension: 2314
    photoshop:ColorMode: 4
    photoshop:ICCProfile: U.S. Web Coated (SWOP) v2
    signature: ccc568a16f75f9ee2ee4ddc5cec80948a7744a2b164f1d19b9bee6c5f3d27d71
    tiff:alpha: associated
    tiff:Compression: 1
    tiff:endian: lsb
    tiff:ImageLength: 2314
    tiff:ImageWidth: 4096
    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;CCD4D7F0F94F08F1D87F553E0C5E6B2A
    tiff:Orientation: 1
    tiff:photometric: separated
    tiff:PhotometricInterpretation: 5
    tiff:PlanarConfiguration: 1
    tiff:ResolutionUnit: 2
    tiff:rows-per-strip: 1
    tiff:SamplesPerPixel: 5
    tiff:software: Adobe Photoshop CS4 Macintosh
    tiff:timestamp: 2011:01:28 17:48:08
    tiff:XResolution: 720000/10000
    tiff:YResolution: 720000/10000
    xmp:CreateDate: 2010-11-11T13:50:35+13:00
    xmp:CreatorTool: Adobe Photoshop CS5 Windows
    xmp:MetadataDate: 2011-01-28T17:48:08-08:00
    xmp:ModifyDate: 2011-01-28T17:48:08-08:00
    xmpMM:DocumentID: xmp.did:237E9E113DF0DF1181AFEB5007335518
    xmpMM:InstanceID: xmp.iid:979DB813482068118A6DA12C6C6849C3
    xmpMM:OriginalDocumentID: xmp.did:237E9E113DF0DF1181AFEB5007335518
  Profiles:
    Profile-8bim: 2444 bytes
    Profile-icc: 557168 bytes
    Profile-iptc: 7 bytes
      unknown[2,0]: 
    Profile-tiff:37724: 17266172 bytes
    Profile-xmp: 17720 bytes
  Artifacts:
    tiff:has-layers: true
    verbose: true
  Tainted: False
  Filesize: 112.6MB
  Number pixels: 9.478M
  Pixels per second: 16.63MB
  User time: 0.740u
  Elapsed time: 0:01.570
  Version: ImageMagick 7.0.3-10 Q16 x86_64 2017-07-11 http://www.imagemagick.org
Image: outputimages/errorfile1.tif
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 766x2254+0+0
  Resolution: 72x72
  Print size: 10.6389x31.3056
  Units: PixelsPerInch
  Type: ColorSeparationAlpha
  Endianess: LSB
  Colorspace: CMYK
  Depth: 16-bit
  Channel depth:
    Cyan: 16-bit
    Magenta: 16-bit
    Yellow: 16-bit
    Black: 16-bit
    Alpha: 16-bit
  Channel statistics:
    Pixels: 1726564
    Cyan:
      min: 2 (3.0518e-05)
      max: 65535 (1)
      mean: 30245.5 (0.461517)
      standard deviation: 22984.3 (0.350718)
      kurtosis: -1.66695
      skewness: -0.494204
      entropy: 0.522386
    Magenta:
      min: 2 (3.0518e-05)
      max: 61205 (0.933928)
      mean: 28658.6 (0.437302)
      standard deviation: 21362.7 (0.325974)
      kurtosis: -1.6307
      skewness: -0.578642
      entropy: 0.476815
    Yellow:
      min: 2 (3.0518e-05)
      max: 65535 (1)
      mean: 27349.7 (0.41733)
      standard deviation: 20500.1 (0.312811)
      kurtosis: -1.63719
      skewness: -0.552683
      entropy: 0.536843
    Black:
      min: 2 (3.0518e-05)
      max: 58707 (0.895811)
      mean: 32951.1 (0.502802)
      standard deviation: 25920.2 (0.395516)
      kurtosis: -1.74103
      skewness: -0.407362
      entropy: 0.574425
    Alpha:
      min: 0 (0)
      max: 65535 (1)
      mean: 35016.3 (0.534315)
      standard deviation: 32598.5 (0.497421)
      kurtosis: -1.97713
      skewness: -0.13738
      entropy: 0.10395
  Image statistics:
    Overall:
      min: 0 (0)
      max: 65535 (1)
      mean: 30844.3 (0.470653)
      standard deviation: 25057.6 (0.382354)
      kurtosis: -1.58629
      skewness: -0.241882
      entropy: 0.442884
  Total ink density: 299.309%
  Alpha: cmyka(0.0030518%,0.0030518%,0.0030518%,0.0030518%,0)   #00020002000200020000
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Alpha color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 766x2254+1753+41
  Origin geometry: +1753+41
  Dispose: Undefined
  Iterations: 0
  Scene: 1 of 2
  Compression: None
  Orientation: TopLeft
  Properties:
    date:create: 2019-04-24T00:08:45-07:00
    date:modify: 2019-04-24T00:08:45-07:00
    dc:format: image/tiff
    exif:ColorSpace: 65535
    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;CA0835B42D901D360F1C3EF77D94001D
    exif:PixelXDimension: 4096
    exif:PixelYDimension: 2314
    label: Layer 0 copy
    photoshop:ColorMode: 4
    photoshop:ICCProfile: U.S. Web Coated (SWOP) v2
    signature: 1a837f75089416476311f1fdaf5b2c7ff79730adfab57d01be41663d864159be
    tiff:alpha: associated
    tiff:Compression: 1
    tiff:endian: lsb
    tiff:ImageLength: 2314
    tiff:ImageWidth: 4096
    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;CCD4D7F0F94F08F1D87F553E0C5E6B2A
    tiff:Orientation: 1
    tiff:photometric: separated
    tiff:PhotometricInterpretation: 5
    tiff:PlanarConfiguration: 1
    tiff:ResolutionUnit: 2
    tiff:rows-per-strip: 1
    tiff:SamplesPerPixel: 5
    tiff:software: Adobe Photoshop CS4 Macintosh
    tiff:timestamp: 2011:01:28 17:48:08
    tiff:XResolution: 720000/10000
    tiff:YResolution: 720000/10000
    xmp:CreateDate: 2010-11-11T13:50:35+13:00
    xmp:CreatorTool: Adobe Photoshop CS5 Windows
    xmp:MetadataDate: 2011-01-28T17:48:08-08:00
    xmp:ModifyDate: 2011-01-28T17:48:08-08:00
    xmpMM:DocumentID: xmp.did:237E9E113DF0DF1181AFEB5007335518
    xmpMM:InstanceID: xmp.iid:979DB813482068118A6DA12C6C6849C3
    xmpMM:OriginalDocumentID: xmp.did:237E9E113DF0DF1181AFEB5007335518
  Profiles:
    Profile-8bim: 2444 bytes
    Profile-icc: 557168 bytes
    Profile-iptc: 7 bytes
      unknown[2,0]: 
    Profile-psd:additional-info: 268 bytes
    Profile-xmp: 17720 bytes
  Artifacts:
    psd:layer.opacity: 65535
    psd:layer.x: 1753
    psd:layer.y: 41
    tiff:has-layers: true
    verbose: true
  Tainted: False
  Filesize: 0B
  Number pixels: 1.727M
  Pixels per second: 302KB
  User time: 5.980u
  Elapsed time: 0:06.710
  Version: ImageMagick 7.0.3-10 Q16 x86_64 2017-07-11 http://www.imagemagick.org
identify: inputImages/errorfile1.tif: wrong data type 7 for "RichTIFFIPTC"; tag ignored. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/918.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Watermarking TIF files gives distorted outputs

Post by fmw42 »

You need a space after input.tif and -set where you have input.tif-set. When I put the space in and use a red image of size 4096x2314 for the input, then I get a red image with the word "copyright" spanning the diagonal.

Code: Select all

magick -size 4096x2314 xc:red -set option:wd "%[fx:0.6*w]" \( -background none -size "%[wd]x" -fill white label:"Copyright" -rotate "315" \) -gravity center -geometry +0+25 -compose over -composite output.tif
Post Reply