I've been using Image::Magick (v6.6.0) to create a thumbnail JPG image of the first page of a PDF with good results for years. Now I'd like to upgrade the base version of Imagemagick (v6.77) but when doing so the resulting image has very jagged text. The same is true when comparing the results of the simple use of the "convert" tool - now I'm getting jagged text.
I've found some solutions online that use the "Super Sampling" approach and that approach works fine when applied to the "convert" command line tool but I can't find the equivalent perl-magick operations.
Previously the code was simple - Read page1 of the PDF and write it as a JPG (simplified for brevity):
Code: Select all
my $magick = Image::Magick->new();
$magick->Read("pdf:$thefile[0]");
$magick->Write("jpg:$outfile");
Code: Select all
convert 'myfile.pdf[0]' outfile.jpg
Code: Select all
convert 'myfile.pdf[0]' -alpha remove -units PixelsPerInch -support 1.1 -resample 72 outfile.jpg
I've tried various things like setting "alpha" to "Off" and/or "matte" to "False" and "alpha" to "Remove" (even though this does appear as an option in the perl-magick docs) but for all of them, when I resample the density of the image to 72 I end up with an all black image.
Example:
Code: Select all
$pdf_magick->Set(units => 'PixelsPerInch');
$pdf_magick->Set(density=>300);
my $rc = $pdf_magick->Read("pdf:${filename_to_read}[0]");
my $err = defined($rc) ? $rc : $@;
if ($err) {
say STDERR "error reading PDF: $error_str";
}
$pdf_magick->Set(alpha => 'Off');
$pdf_magick->Resample(density => 72, support=>1.1);
$pdf_magick->Write("jpg:$outfile_name");
Any help is much appreciated!
-Joel