convert PDF to PNG gives gray instead of white background

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jeffATwork
Posts: 30
Joined: 2009-01-02T14:14:45-07:00
Location: Minneapolis, MN

convert PDF to PNG gives gray instead of white background

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
jeffATwork
Posts: 30
Joined: 2009-01-02T14:14:45-07:00
Location: Minneapolis, MN

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

Post 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.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post 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:
jeffATwork
Posts: 30
Joined: 2009-01-02T14:14:45-07:00
Location: Minneapolis, MN

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

Post by jeffATwork »

My sysadmin is a splendid person! :-) Does anyone have recommendation about what version to shoot for?

Thanks!
-J
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
Post Reply