Scene Attribute being ignored by Write
Posted: 2017-09-27T09:23:25-07:00
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
to get files tiffp0015.tif though testp0018.tif (for a 4-page PDF). I tried to translate this into PerlMagick with the following code:
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:
Variant 2:
And just in case the order of attributes made a difference in the "Write" command:
Variant 3:
Code: Select all
'convert -density 240x240 -compress Group4 -scene 15 test.pdf testp%04d.tif'
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");
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");
Code: Select all
$image->Read($filename);
$image->Write(filename=>"testp%04d.tif",
compression=>'Group4',
density=>"240x240",
scene=>15);
Variant 3:
Code: Select all
$image->Read($filename);
$image->Write(scene=>15,
filename=>"testp%04d.tif",
compression=>'Group4',
density=>"240x240");