Tiff comparison failure

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
vinayzz
Posts: 9
Joined: 2018-10-10T02:23:01-07:00
Authentication code: 1152

Tiff comparison failure

Post by vinayzz »

Hi,

I am using a library to create TIFF files from JPEG and PNG source files. I need to put a check using IM for the PSNR metric. The same works when I convert JPEG to PNG or PNG to JPEG but fails with "compare: image widths or heights differ" error while tiff comparison.

I have tried with multiple files and also with several runs. Each run produces a supposedly different dimensions. Whereas the online tool DiffNow shows no difference at all.

Please let me know if there is an open bug.

File 1:

Code: Select all

Image: D:\spice\vinaygup_spice_main\flite\tools\flite-test\testsuite\baselines\JPEGTIFF\png_test_subs_blob\FliteTest_1_100A62_ChristmasPark.jpg\1_100A62_ChristmasPark.TIFF
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 613x460+0+0
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: LSB
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 281980
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 113.224 (0.444015)
      standard deviation: 77.5487 (0.304113)
      kurtosis: -1.36947
      skewness: 0.211514
      entropy: 0.976884
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 105.201 (0.412554)
      standard deviation: 75.9169 (0.297713)
      kurtosis: -1.10052
      skewness: 0.584713
      entropy: 0.954303
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 104.368 (0.409288)
      standard deviation: 83.0611 (0.32573)
      kurtosis: -1.18498
      skewness: 0.504372
      entropy: 0.954011
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 107.598 (0.421952)
      standard deviation: 78.9015 (0.309418)
      kurtosis: -1.22598
      skewness: 0.432183
      entropy: 0.961733
  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: 613x460+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 0 of 4
  Compression: JPEG
  Orientation: TopLeft
  Properties:
    date:create: 2018-10-09T16:04:21+06:00
    date:modify: 2018-10-09T16:04:21+06:00
    jpeg:sampling-factor: 2x2
    signature: f4b4b7d6a7eb564d123eddf15357068f6b5219dedf21531c470cb5ff2a986d68
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: YCBCR
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 297KB
  Number pixels: 282K
  Pixels per second: 46.99MB
  User time: 0.000u
  Elapsed time: 0:01.006
  Version: ImageMagick 7.0.1-3 Q16 x64 2016-05-09 http://www.imagemagick.org
Image: D:\spice\vinaygup_spice_main\flite\tools\flite-test\testsuite\baselines\JPEGTIFF\png_test_subs_blob\FliteTest_1_100A62_ChristmasPark.jpg\1_100A62_ChristmasPark.TIFF
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 306x230+0+0
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: LSB
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 70380
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 113.256 (0.44414)
      standard deviation: 77.1491 (0.302546)
      kurtosis: -1.33885
      skewness: 0.205259
      entropy: 0.975979
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 105.346 (0.413121)
      standard deviation: 75.6333 (0.296601)
      kurtosis: -1.06385
      skewness: 0.595697
      entropy: 0.954529
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 104.417 (0.409477)
      standard deviation: 82.5755 (0.323826)
      kurtosis: -1.16947
      skewness: 0.505909
      entropy: 0.955783
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 107.673 (0.422246)
      standard deviation: 78.5092 (0.307879)
      kurtosis: -1.20095
      skewness: 0.434048
      entropy: 0.962097
  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: 306x230+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 1 of 4
  Compression: Zip
  Orientation: TopLeft
  Properties:
    date:create: 2018-10-09T16:04:21+06:00
    date:modify: 2018-10-09T16:04:21+06:00
    signature: 5f9aa976cb6e67dec92887ff24145b6241cb34fb79e72d98496f39fe4883d48d
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:subfiletype: REDUCEDIMAGE
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 297KB
  Number pixels: 70.4K
  Pixels per second: 398KB
  User time: 0.531u
  Elapsed time: 0:01.177
  Version: ImageMagick 7.0.1-3 Q16 x64 2016-05-09 http://www.imagemagick.org
Image: D:\spice\vinaygup_spice_main\flite\tools\flite-test\testsuite\baselines\JPEGTIFF\png_test_subs_blob\FliteTest_1_100A62_ChristmasPark.jpg\1_100A62_ChristmasPark.TIFF
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 153x115+0+0
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: LSB
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 17595
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 113.416 (0.44477)
      standard deviation: 76.9472 (0.301754)
      kurtosis: -1.30214
      skewness: 0.197486
      entropy: 0.978734
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 105.39 (0.413293)
      standard deviation: 75.5045 (0.296096)
      kurtosis: -1.02425
      skewness: 0.594664
      entropy: 0.959973
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 104.514 (0.40986)
      standard deviation: 82.4039 (0.323153)
      kurtosis: -1.16038
      skewness: 0.499917
      entropy: 0.958424
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 107.773 (0.422641)
      standard deviation: 78.3416 (0.307222)
      kurtosis: -1.17473
      skewness: 0.429049
      entropy: 0.96571
  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: 153x115+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 2 of 4
  Compression: Zip
  Orientation: TopLeft
  Properties:
    date:create: 2018-10-09T16:04:21+06:00
    date:modify: 2018-10-09T16:04:21+06:00
    signature: 7b383cda6023b5576d08d19e7f82954485b1d049d70dc147e07bb2cbfde70220
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:subfiletype: REDUCEDIMAGE
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 297KB
  Number pixels: 17.6K
  Pixels per second: 60.7KB
  User time: 0.875u
  Elapsed time: 0:01.290
  Version: ImageMagick 7.0.1-3 Q16 x64 2016-05-09 http://www.imagemagick.org
Image: D:\spice\vinaygup_spice_main\flite\tools\flite-test\testsuite\baselines\JPEGTIFF\png_test_subs_blob\FliteTest_1_100A62_ChristmasPark.jpg\1_100A62_ChristmasPark.TIFF
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 77x58+0+0
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: LSB
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 4466
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 113.554 (0.445308)
      standard deviation: 74.0268 (0.290301)
      kurtosis: -1.2341
      skewness: 0.213991
      entropy: 0.979307
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 105.385 (0.413273)
      standard deviation: 72.471 (0.2842)
      kurtosis: -0.914036
      skewness: 0.647862
      entropy: 0.959365
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 104.547 (0.40999)
      standard deviation: 79.4091 (0.311408)
      kurtosis: -1.07555
      skewness: 0.531697
      entropy: 0.961749
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 107.829 (0.422857)
      standard deviation: 75.3609 (0.295533)
      kurtosis: -1.08966
      skewness: 0.462091
      entropy: 0.966807
  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: 77x58+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 3 of 4
  Compression: Zip
  Orientation: TopLeft
  Properties:
    date:create: 2018-10-09T16:04:21+06:00
    date:modify: 2018-10-09T16:04:21+06:00
    signature: 4658f30382085da2805add44fd4e511add4fe2a1e28efca375c2adec4a905f4d
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:subfiletype: REDUCEDIMAGE
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 297KB
  Number pixels: 4.47K
  Pixels per second: 11.5KB
  User time: 1.016u
  Elapsed time: 0:01.388
  Version: ImageMagick 7.0.1-3 Q16 x64 2016-05-09 http://www.imagemagick.org

File 2:

Code: Select all

Image: D:\spice\vinaygup_spice_main\flite\tools\flite-test\test-output\JPEGTIFF\png_test_subs_blob\FliteTest_1_100A62_ChristmasPark.jpg\1_100A62_ChristmasPark.TIFF
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 613x460+0+0
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: LSB
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 281980
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 113.224 (0.444015)
      standard deviation: 77.5487 (0.304113)
      kurtosis: -1.36947
      skewness: 0.211514
      entropy: 0.976884
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 105.201 (0.412554)
      standard deviation: 75.9169 (0.297713)
      kurtosis: -1.10052
      skewness: 0.584713
      entropy: 0.954303
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 104.368 (0.409288)
      standard deviation: 83.0611 (0.32573)
      kurtosis: -1.18498
      skewness: 0.504372
      entropy: 0.954011
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 107.598 (0.421952)
      standard deviation: 78.9015 (0.309418)
      kurtosis: -1.22598
      skewness: 0.432183
      entropy: 0.961733
  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: 613x460+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 0 of 4
  Compression: JPEG
  Orientation: TopLeft
  Properties:
    date:create: 2018-10-10T12:30:33+05:00
    date:modify: 2018-10-10T12:30:33+05:00
    jpeg:sampling-factor: 2x2
    signature: f4b4b7d6a7eb564d123eddf15357068f6b5219dedf21531c470cb5ff2a986d68
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: YCBCR
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 297KB
  Number pixels: 282K
  Pixels per second: 47.01MB
  User time: 0.000u
  Elapsed time: 0:01.005
  Version: ImageMagick 7.0.1-3 Q16 x64 2016-05-09 http://www.imagemagick.org
Image: D:\spice\vinaygup_spice_main\flite\tools\flite-test\test-output\JPEGTIFF\png_test_subs_blob\FliteTest_1_100A62_ChristmasPark.jpg\1_100A62_ChristmasPark.TIFF
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 306x230+0+0
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: LSB
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 70380
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 113.256 (0.44414)
      standard deviation: 77.1491 (0.302546)
      kurtosis: -1.33885
      skewness: 0.205259
      entropy: 0.975979
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 105.346 (0.413121)
      standard deviation: 75.6333 (0.296601)
      kurtosis: -1.06385
      skewness: 0.595697
      entropy: 0.954529
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 104.417 (0.409477)
      standard deviation: 82.5755 (0.323826)
      kurtosis: -1.16947
      skewness: 0.505909
      entropy: 0.955783
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 107.673 (0.422246)
      standard deviation: 78.5092 (0.307879)
      kurtosis: -1.20095
      skewness: 0.434048
      entropy: 0.962097
  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: 306x230+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 1 of 4
  Compression: Zip
  Orientation: TopLeft
  Properties:
    date:create: 2018-10-10T12:30:33+05:00
    date:modify: 2018-10-10T12:30:33+05:00
    signature: 5f9aa976cb6e67dec92887ff24145b6241cb34fb79e72d98496f39fe4883d48d
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:subfiletype: REDUCEDIMAGE
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 297KB
  Number pixels: 70.4K
  Pixels per second: 443KB
  User time: 0.453u
  Elapsed time: 0:01.158
  Version: ImageMagick 7.0.1-3 Q16 x64 2016-05-09 http://www.imagemagick.org
Image: D:\spice\vinaygup_spice_main\flite\tools\flite-test\test-output\JPEGTIFF\png_test_subs_blob\FliteTest_1_100A62_ChristmasPark.jpg\1_100A62_ChristmasPark.TIFF
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 153x115+0+0
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: LSB
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 17595
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 113.416 (0.44477)
      standard deviation: 76.9472 (0.301754)
      kurtosis: -1.30214
      skewness: 0.197486
      entropy: 0.978734
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 105.39 (0.413293)
      standard deviation: 75.5045 (0.296096)
      kurtosis: -1.02425
      skewness: 0.594664
      entropy: 0.959973
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 104.514 (0.40986)
      standard deviation: 82.4039 (0.323153)
      kurtosis: -1.16038
      skewness: 0.499917
      entropy: 0.958424
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 107.773 (0.422641)
      standard deviation: 78.3416 (0.307222)
      kurtosis: -1.17473
      skewness: 0.429049
      entropy: 0.96571
  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: 153x115+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 2 of 4
  Compression: Zip
  Orientation: TopLeft
  Properties:
    date:create: 2018-10-10T12:30:33+05:00
    date:modify: 2018-10-10T12:30:33+05:00
    signature: 7b383cda6023b5576d08d19e7f82954485b1d049d70dc147e07bb2cbfde70220
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:subfiletype: REDUCEDIMAGE
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 297KB
  Number pixels: 17.6K
  Pixels per second: 63.5KB
  User time: 0.875u
  Elapsed time: 0:01.277
  Version: ImageMagick 7.0.1-3 Q16 x64 2016-05-09 http://www.imagemagick.org
Image: D:\spice\vinaygup_spice_main\flite\tools\flite-test\test-output\JPEGTIFF\png_test_subs_blob\FliteTest_1_100A62_ChristmasPark.jpg\1_100A62_ChristmasPark.TIFF
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 77x58+0+0
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: LSB
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 4466
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 113.554 (0.445308)
      standard deviation: 74.0268 (0.290301)
      kurtosis: -1.2341
      skewness: 0.213991
      entropy: 0.979307
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 105.385 (0.413273)
      standard deviation: 72.471 (0.2842)
      kurtosis: -0.914036
      skewness: 0.647862
      entropy: 0.959365
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 104.547 (0.40999)
      standard deviation: 79.4091 (0.311408)
      kurtosis: -1.07555
      skewness: 0.531697
      entropy: 0.961749
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 107.829 (0.422857)
      standard deviation: 75.3609 (0.295533)
      kurtosis: -1.08966
      skewness: 0.462091
      entropy: 0.966807
  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: 77x58+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 3 of 4
  Compression: Zip
  Orientation: TopLeft
  Properties:
    date:create: 2018-10-10T12:30:33+05:00
    date:modify: 2018-10-10T12:30:33+05:00
    signature: 4658f30382085da2805add44fd4e511add4fe2a1e28efca375c2adec4a905f4d
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:subfiletype: REDUCEDIMAGE
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 297KB
  Number pixels: 4.47K
  Pixels per second: 10.9KB
  User time: 1.047u
  Elapsed time: 0:01.408
  Version: ImageMagick 7.0.1-3 Q16 x64 2016-05-09 http://www.imagemagick.org
Regards
Vinay Gupta
vinayzz
Posts: 9
Joined: 2018-10-10T02:23:01-07:00
Authentication code: 1152

Re: Tiff comparison failure

Post by vinayzz »

http://www.multipole.org/discourse-serv ... 43c3afa8a8
This is the same use case. A complex workaround will be to keep a diff.png file and compare it with the new diff file.

Is there any shorter or better way for multipage tiff files?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Tiff comparison failure

Post by snibgo »

vinayzz wrote:... fails with "compare: image widths or heights differ" error ...
IM's "compare" does a pixel-by-pixel comparison, so it doesn't work when the two images are different sizes. You might resize or scale one image to be the same size as the other, or "-crop" or "-extent" it, or whatever.

"compare" also only works with two inputs. If you have a multi-image TIFF, you could write a script that compared each pair of images. Or, as Anthony says on the other thread, use "-compose Difference -layers composite" to get one multi-image set of differences, and then do some maths on the results.
snibgo's IM pages: im.snibgo.com
vinayzz
Posts: 9
Joined: 2018-10-10T02:23:01-07:00
Authentication code: 1152

Re: Tiff comparison failure

Post by vinayzz »

snibgo wrote: 2018-10-10T06:28:23-07:00
vinayzz wrote:... fails with "compare: image widths or heights differ" error ...
IM's "compare" does a pixel-by-pixel comparison, so it doesn't work when the two images are different sizes. You might resize or scale one image to be the same size as the other, or "-crop" or "-extent" it, or whatever.

"compare" also only works with two inputs. If you have a multi-image TIFF, you could write a script that compared each pair of images. Or, as Anthony says on the other thread, use "-compose Difference -layers composite" to get one multi-image set of differences, and then do some maths on the results.
Antony's solution creates a tiff with diff appropriate only for first layer. All other layers are imposed on the first itself and not on respective layer.
A solution which I would suggest can be reviewed by you: Convert TIFF to PNG images - creating 4 different images and then compare the counterpart images from new output TIFF->PNG conversions. Do you foresee any loss of data here?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Tiff comparison failure

Post by snibgo »

I know nothing about layers, and IM doesn't deal with layers as far as I know.

A TIFF file many contain many images. When two tiff files contain the same number of images, they can be compared pair-wise. Is that what you mean?
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: Tiff comparison failure

Post by fmw42 »

Imagemagick can process multi-page TIFFs, but not layered tiffs. Can you post two tiffs for us to test if multilayer or multipage? If the latter, then one can compare them likely using -layers composite. But I would have to test that. Otherwise as snibgo said, you would need to separate pages and compare them pair wise. Get the PSNR from each and combine into one value.
vinayzz
Posts: 9
Joined: 2018-10-10T02:23:01-07:00
Authentication code: 1152

Re: Tiff comparison failure

Post by vinayzz »

fmw42 wrote: 2018-10-10T09:54:04-07:00 Imagemagick can process multi-page TIFFs, but not layered tiffs. Can you post two tiffs for us to test if multilayer or multipage? If the latter, then one can compare them likely using -layers composite. But I would have to test that. Otherwise as snibgo said, you would need to separate pages and compare them pair wise. Get the PSNR from each and combine into one value.
I am sorry but I have TIFF files with images and not layers. My mistake in the nomenclature. My tiff is generic multi image tiff. I dont know how to upload the image on this forum but you can create it using PS from any image with layers enabled.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Tiff comparison failure

Post by snibgo »

To get the PSNR metrics pair-wise, I suggest you use a script to walk through the pairs using [0], [1] etc.
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: Tiff comparison failure

Post by fmw42 »

This forum does not allow direct uploads. You should post your images to some free hosting service such as dropbox.com that won't change the format (or zip them first) and put the URLs here.

snibgo's suggestion is the proper way. You can make script loop over each page of the image and do the compare per page

compare -metric PSNR image1.tif[0] image2.tif[0] null:
compare -metric PSNR image1.tif[1] image2.tif[1] null:
...

But do it in a loop over a variable for the page number.
vinayzz
Posts: 9
Joined: 2018-10-10T02:23:01-07:00
Authentication code: 1152

Re: Tiff comparison failure

Post by vinayzz »

fmw42 wrote: 2018-10-11T08:47:12-07:00 This forum does not allow direct uploads. You should post your images to some free hosting service such as dropbox.com that won't change the format (or zip them first) and put the URLs here.

snibgo's suggestion is the proper way. You can make script loop over each page of the image and do the compare per page

compare -metric PSNR image1.tif[0] image2.tif[0] null:
compare -metric PSNR image1.tif[1] image2.tif[1] null:
...

But do it in a loop over a variable for the page number.
Yes. This will work for me. Could you please also help me with getting the number of images in the tiff file?
As a workaround I can convert tiff to PNG and count the number of files created. But a more suitable solution would be very helpful.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Tiff comparison failure

Post by fmw42 »

Code: Select all

convert lena1.tif -format "%n\n" info: | head -n 1
This is unix syntax piping to head -n 1 to get just the first number returned. Imagemagick will return the same number as many times as you have image in the input image chain. I am not sure if Windows had the head command or something like it.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Tiff comparison failure

Post by fmw42 »

Here is another way to do it in one command line when you have two multi-page tiff files of the same number of pages.

I use IM 7 magick rather than convert since IM 7 is by default in HDRI mode, so has better accuracy. I get slightly different values for IM 6 convert.

Code: Select all

magick image1.tif null: image2.tif -compose difference -layers composite -evaluate pow 2 -format "%[fx:mean<=1.0e-11?inf:20*log(1/(sqrt(mean)))]\n" info:
This approach using -compose difference -layers composite -evaluate pow 2 and the fx expression gives me the exact same values for single page pair of tiffs with magick compare in IM 7.

An equivalent command that is slightly more efficient is:

Code: Select all

magick image1.tif null: image2.tif -compose difference -layers composite -evaluate pow 2 -format "%[fx:mean<=1.0e-11?inf:10*log(1/mean)]\n" info:
vinayzz
Posts: 9
Joined: 2018-10-10T02:23:01-07:00
Authentication code: 1152

Re: Tiff comparison failure

Post by vinayzz »

This is resolved for me. Thanks everyone!
Post Reply