Scene Attribute being ignored by Write

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
BrentD
Posts: 6
Joined: 2014-12-05T10:17:02-07:00
Authentication code: 6789

Scene Attribute being ignored by Write

Post by BrentD »

I am trying to use PerlMagick to convert PDFs into multiple TIFF images. For the most part everything is working, except for the file numbering. Normally I'd just call

Code: Select all

'convert -density 240x240 -compress Group4 -scene 15 test.pdf testp%04d.tif'
to get files tiffp0015.tif though testp0018.tif (for a 4-page PDF). I tried to translate this into PerlMagick with the following code:

Code: Select all

#!/usr/bin/perl
use strict;
use warnings;
use Image::Magick;

# Cleanup results of prior runs
unlink (glob("*.tif"));

my $image = Image::Magick->new;
my $filename = "test.pdf";

$image->Read($filename);

# Check scene for Debugging
my $p = $image->Get('scene');
print "\n\nScene1: $p\n";

#Set scene number to desired starting page
$image->Set(scene=>15);

# Check scene for Debugging again
$p = $image->Get('scene');
print "Scene2: $p\n\n";

# Write the files.
$image->Write(filename=>"testp%04d.tif",
              compression=>'Group4',
              density=>"240x240");
But it always outputs testp0000.tif - testp0003.tiff. I've got some debugging in the above code to make sure the scene attribute is being set correctly, and it appears that it is. It's acting like the "scene" attribute is just being ignored by the "Write" method. (Also the API says the return value for the Write method should be the number of files written, but it doesn't appear to be returning anything. But that's another issue altogether.)

I've also tried the following variants:

Variant 1:

Code: Select all

$image->Read($filename);
$image->[0]->Set(scene=>15);
$image->Write(filename=>"testp%04d.tif",
              compression=>'Group4',
              density=>"240x240");
Variant 2:

Code: Select all

$image->Read($filename);
$image->Write(filename=>"testp%04d.tif",
              compression=>'Group4',
              density=>"240x240",
              scene=>15);
And just in case the order of attributes made a difference in the "Write" command:

Variant 3:

Code: Select all

$image->Read($filename);
$image->Write(scene=>15,
              filename=>"testp%04d.tif",
              compression=>'Group4',
              density=>"240x240");
Post Reply