Page 1 of 1

convert PDF to PNG gives gray instead of white background

Posted: 2015-07-20T13:00:24-07:00
by jeffATwork
I'm using Perl::Magick to convert PDFs containing black text on a white background to PNGs using ImageMagick 6.7.7-10 2014-03-06 Q16.
The code looks like:

Code: Select all

 
 my $image = Image::Magick->new( density => $density,
                                    units => 'PixelsPerInch' );
    my $err = $image->Read( $input_path );
    if ( "$err" ) {
	$self->logger->logdie( "Read error: $err" );
    }
    $image->Write( $output_path );
where the input path points to a PDF file and the output to a PNG file.

The resulting PNGs have a gray background and seem to have acquired alpha/matte channels.

When I convert the same files via the command line using ImageMagick 6.9.0-9 Q16 x86_64 2015-03-02, I get what I want, black text on a white background.

This should be simple. How can I get what I want?

Thanks,
-J

Re: convert PDF to PNG gives gray instead of white background

Posted: 2015-07-20T13:12:42-07:00
by fmw42
IM 6.7.7-10 was at a time when IM was undergoing some major changes between linear and sRGB and there were likely bugs in that version. You will need to upgrade as you seem to have found out using 6.9.0.9. Does your Perlmagick code work in the 6.9.0.9 version? Does your command line work in the 6.7.7.10 version? That will tell you whether it is the IM version of your PerlMagick code.

see
viewtopic.php?f=4&t=21269

Re: convert PDF to PNG gives gray instead of white background

Posted: 2015-07-20T13:25:51-07:00
by jeffATwork
Thanks. Output from 6.7.7-10 via the command line doesn't have the background color issue, but is of such low quality that it is unreadable. I'll see what I can do about upgrading. We're running ubuntu 14.04 LTS and I'm not sure what my sysadmin will do for me.

Re: convert PDF to PNG gives gray instead of white background

Posted: 2015-07-20T13:34:06-07:00
by Bonzo

Code: Select all

I'm not sure what my sysadmin will do for me.
Tell him he is there to support you and to do what you want and see what happens :lol:

Re: convert PDF to PNG gives gray instead of white background

Posted: 2015-07-20T14:40:08-07:00
by jeffATwork
My sysadmin is a splendid person! :-) Does anyone have recommendation about what version to shoot for?

Thanks!
-J

Re: convert PDF to PNG gives gray instead of white background

Posted: 2015-07-20T14:57:57-07:00
by fmw42
The most current as possible. But see the link about the change of colorspace to see what version was safe after the change.

Probably 6.8.7.3 or higher, but there were some buggy versions in the 6.9.1x range also. But 6.9.1.5 or higher, I think are safe.