Resample broken?

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
mmlenz
Posts: 23
Joined: 2012-05-30T08:08:21-07:00
Authentication code: 13

Resample broken?

Post by mmlenz »

Code: Select all

#!/usr/bin/perl

use strict;
use warnings;
require Image::Magick;

$ARGV[0] || die;

# obtain image data
my $magick = Image::Magick->new();
$magick->Read($ARGV[0]) && die;
my $x = $magick->Get('x-resolution');
my $y = $magick->Get('y-resolution');

print "x = $x, y = $y\n";

if ($x != $y) {
    $magick->Resample($x);
    $magick->Write('new'.$ARGV[0]);
}

exit;
I'm using this to fix fax tiffs for import into crappy document imaging systems that don't "understand" the disproportionate resolutions.

Problem is that the Resample seems to be broken and it's producing a document where all the pages are black.

perlmagick/xenial-updates,xenial-updates,xenial-security,xenial-security,now 8:6.8.9.9-7ubuntu5.3
and
perlmagick/stable 8:6.8.9.9-5+deb8u6 all

Am I missing something?
  • convert original.tif -resample <X res> new.tif
works just fine.

More details:

Code: Select all

Original
273068 Dec  2 11:07 d4df352cdd9ac5d08ab6107e08c5d548e183d716.tif

Resampled (notice the file size)
    2544 Dec  2 12:10 newd4df352cdd9ac5d08ab6107e08c5d548e183d716.tif

Image: d4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 1728x1087+0+0
  Resolution: 204x98
  Print size: 8.47059x11.0918
  Units: PixelsPerInch
  Type: Bilevel
  Endianess: LSB
  Colorspace: Gray
  Depth: 1-bit
  Channel depth:
    gray: 1-bit
  Channel statistics:
    Pixels: 1878336
    Gray:
      min: 0 (0)
      max: 1 (1)
      mean: 0.936506 (0.936506)
      standard deviation: 0.243849 (0.243849)
      kurtosis: 10.8173
      skewness: -3.58013
  Colors: 2
  Histogram:
    119263: (  0,  0,  0) #000000 gray(0)
   1759073: (255,255,255) #FFFFFF gray(255)
  Rendering intent: Undefined
  Gamma: 0.454545
  Background color: gray(255)
  Border color: gray(223)
  Matte color: gray(189)
  Transparent color: gray(0)
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 1728x1087+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 0 of 3
  Compression: Group4
  Orientation: TopLeft
  Properties:
    comment: <UNSPECIFIED>
2163328041
8883700556
    date:create: 2016-12-02T11:07:42-06:00
    date:modify: 2016-12-02T11:07:13-06:00
    signature: 695a0b42781dc63019fbd46dd7a31c971ff1d2114b8b3b4ebe5afb57d6ea7192
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:hostcomputer: engfax01
    tiff:make: LT V.92 1.0 MT5634SMI-V92 DATA/FAX MODEM VERSION 1.32I
    tiff:model: LT V.92 1.0 MT5634SMI-V92 Data/Fax Modem Version 1.32i
    tiff:photometric: min-is-white
    tiff:rows-per-strip: 4294967295
    tiff:software: HylaFAX (tm) Version 5.5.1
    tiff:timestamp: 2016:10:19 07:23:36
  Artifacts:
    filename: d4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
    verbose: true
  Tainted: False
  Filesize: 273KB
  Number pixels: 1.878M
  Pixels per second: 62.61MB
  User time: 0.030u
  Elapsed time: 0:01.029
  Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29 http://www.imagemagick.org
Image: d4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 1728x1087+0+0
  Resolution: 204x98
  Print size: 8.47059x11.0918
  Units: PixelsPerInch
  Type: Bilevel
  Endianess: LSB
  Colorspace: Gray
  Depth: 1-bit
  Channel depth:
    gray: 1-bit
  Channel statistics:
    Pixels: 1878336
    Gray:
      min: 0 (0)
      max: 1 (1)
      mean: 0.146693 (0.146693)
      standard deviation: 0.353799 (0.353799)
      kurtosis: 1.98889
      skewness: 1.99722
  Colors: 2
  Histogram:
   1602798: (  0,  0,  0) #000000 gray(0)
    275538: (255,255,255) #FFFFFF gray(255)
  Rendering intent: Undefined
  Gamma: 0.454545
  Background color: gray(255)
  Border color: gray(223)
  Matte color: gray(189)
  Transparent color: gray(0)
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 1728x1087+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 1 of 3
  Compression: Group4
  Orientation: TopLeft
  Properties:
    comment: <UNSPECIFIED>
2163328041
8883700556
    date:create: 2016-12-02T11:07:42-06:00
    date:modify: 2016-12-02T11:07:13-06:00
    signature: 4040d3230ff017f302886d6a7302f2f6fa99864ddd605bd73b28b46291f76c5d
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:hostcomputer: engfax01
    tiff:make: LT V.92 1.0 MT5634SMI-V92 DATA/FAX MODEM VERSION 1.32I
    tiff:model: LT V.92 1.0 MT5634SMI-V92 Data/Fax Modem Version 1.32i
    tiff:photometric: min-is-white
    tiff:rows-per-strip: 4294967295
    tiff:software: HylaFAX (tm) Version 5.5.1
    tiff:timestamp: 2016:10:19 07:23:42
  Artifacts:
    filename: d4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
    verbose: true
  Tainted: False
  Filesize: 273KB
  Number pixels: 1.878M
  Pixels per second: 2.683MB
  User time: 0.780u
  Elapsed time: 0:01.699
  Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29 http://www.imagemagick.org
Image: d4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 1728x1087+0+0
  Resolution: 204x98
  Print size: 8.47059x11.0918
  Units: PixelsPerInch
  Type: Bilevel
  Endianess: LSB
  Colorspace: Gray
  Depth: 1-bit
  Channel depth:
    gray: 1-bit
  Channel statistics:
    Pixels: 1878336
    Gray:
      min: 0 (0)
      max: 1 (1)
      mean: 0.138571 (0.138571)
      standard deviation: 0.345498 (0.345498)
      kurtosis: 2.37738
      skewness: 2.09222
  Colors: 2
  Histogram:
   1618053: (  0,  0,  0) #000000 gray(0)
    260283: (255,255,255) #FFFFFF gray(255)
  Rendering intent: Undefined
  Gamma: 0.454545
  Background color: gray(255)
  Border color: gray(223)
  Matte color: gray(189)
  Transparent color: gray(0)
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 1728x1087+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 2 of 3
  Compression: Group4
  Orientation: TopLeft
  Properties:
    comment: <UNSPECIFIED>
2163328041
8883700556
    date:create: 2016-12-02T11:07:42-06:00
    date:modify: 2016-12-02T11:07:13-06:00
    signature: 4e36363bb6b222aa3823f42397bf9628c738cb2a2aa1836f0d715b84d314e6d0
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:hostcomputer: engfax01
    tiff:make: LT V.92 1.0 MT5634SMI-V92 DATA/FAX MODEM VERSION 1.32I
    tiff:model: LT V.92 1.0 MT5634SMI-V92 Data/Fax Modem Version 1.32i
    tiff:photometric: min-is-white
    tiff:rows-per-strip: 4294967295
    tiff:software: HylaFAX (tm) Version 5.5.1
    tiff:timestamp: 2016:10:19 07:24:29
  Artifacts:
    filename: d4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
    verbose: true
  Tainted: False
  Filesize: 273KB
  Number pixels: 1.878M
  Pixels per second: 1.491MB
  User time: 1.410u
  Elapsed time: 0:02.259
  Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29 http://www.imagemagick.org





Image: newd4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 1728x2263+0+0
  Resolution: 204x204
  Print size: 8.47059x11.0931
  Units: PixelsPerInch
  Type: Bilevel
  Endianess: LSB
  Colorspace: Gray
  Depth: 1-bit
  Channel depth:
    gray: 1-bit
  Channel statistics:
    Pixels: 3910464
    Gray:
      min: 0 (0)
      max: 1 (1)
      mean: 0.000395094 (0.000395094)
      standard deviation: 0.019873 (0.019873)
      kurtosis: 2526.05
      skewness: 50.2797
  Colors: 2
  Histogram:
   3908919: (  0,  0,  0) #000000 gray(0)
      1545: (255,255,255) #FFFFFF gray(255)
  Rendering intent: Undefined
  Gamma: 0.454545
  Background color: gray(255)
  Border color: gray(223)
  Matte color: gray(189)
  Transparent color: gray(0)
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 1728x2263+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 0 of 3
  Compression: Group4
  Orientation: TopLeft
  Properties:
    date:create: 2016-12-02T12:10:55-06:00
    date:modify: 2016-12-02T12:10:55-06:00
    signature: 6a4b5d9358b4aafb411694668815a755bdf83a6e73b93fa52bd5bdc2ee070487
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: min-is-white
    tiff:rows-per-strip: 2263
  Artifacts:
    filename: newd4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
    verbose: true
  Tainted: False
  Filesize: 2.54KB
  Number pixels: 3.91M
  Pixels per second: 78.21MB
  User time: 0.050u
  Elapsed time: 0:01.050
  Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29 http://www.imagemagick.org
Image: newd4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 1728x2263+0+0
  Resolution: 204x204
  Print size: 8.47059x11.0931
  Units: PixelsPerInch
  Type: Bilevel
  Endianess: LSB
  Colorspace: Gray
  Depth: 1-bit
  Channel depth:
    gray: 1-bit
  Channel statistics:
    Pixels: 3910464
    Gray:
      min: 0 (0)
      max: 1 (1)
      mean: 2.81297e-05 (2.81297e-05)
      standard deviation: 0.00530367 (0.00530367)
      kurtosis: 35544.7
      skewness: 188.538
  Colors: 2
  Histogram:
   3910354: (  0,  0,  0) #000000 gray(0)
       110: (255,255,255) #FFFFFF gray(255)
  Rendering intent: Undefined
  Gamma: 0.454545
  Background color: gray(255)
  Border color: gray(223)
  Matte color: gray(189)
  Transparent color: gray(0)
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 1728x2263+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 1 of 3
  Compression: Group4
  Orientation: TopLeft
  Properties:
    date:create: 2016-12-02T12:10:55-06:00
    date:modify: 2016-12-02T12:10:55-06:00
    signature: 956819e12e70ec53148174acd62dc05631531070f980afb437d1cbe4358e3648
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: min-is-white
    tiff:rows-per-strip: 2263
  Artifacts:
    filename: newd4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
    verbose: true
  Tainted: False
  Filesize: 2.54KB
  Number pixels: 3.91M
  Pixels per second: 3.371MB
  User time: 1.280u
  Elapsed time: 0:02.160
  Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29 http://www.imagemagick.org
Image: newd4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 1728x2263+0+0
  Resolution: 204x204
  Print size: 8.47059x11.0931
  Units: PixelsPerInch
  Type: Bilevel
  Endianess: LSB
  Colorspace: Gray
  Depth: 1-bit
  Channel depth:
    gray: 1-bit
  Channel statistics:
    Pixels: 3910464
    Gray:
      min: 0 (0)
      max: 1 (1)
      mean: 2.73625e-05 (2.73625e-05)
      standard deviation: 0.00523084 (0.00523084)
      kurtosis: 36541.4
      skewness: 191.163
  Colors: 2
  Histogram:
   3910357: (  0,  0,  0) #000000 gray(0)
       107: (255,255,255) #FFFFFF gray(255)
  Rendering intent: Undefined
  Gamma: 0.454545
  Background color: gray(255)
  Border color: gray(223)
  Matte color: gray(189)
  Transparent color: gray(0)
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 1728x2263+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 2 of 3
  Compression: Group4
  Orientation: TopLeft
  Properties:
    date:create: 2016-12-02T12:10:55-06:00
    date:modify: 2016-12-02T12:10:55-06:00
    signature: 8df5f80d75cf7f0d172b74ab67e90cb884c986f351ab98a44aaec056cd204110
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: min-is-white
    tiff:rows-per-strip: 2263
  Artifacts:
    filename: newd4df352cdd9ac5d08ab6107e08c5d548e183d716.tif
    verbose: true
  Tainted: False
  Filesize: 2.54KB
  Number pixels: 3.91M
  Pixels per second: 1.723MB
  User time: 2.460u
  Elapsed time: 0:03.269
  Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29 http://www.imagemagick.org
mmlenz
Posts: 23
Joined: 2012-05-30T08:08:21-07:00
Authentication code: 13

Re: Resample broken?

Post by mmlenz »

Bump. Still stumped on this one.
Post Reply