addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwchatcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgoogleimageimagesinstagramlinklocation-pinmagnifying-glassmailminusmoremuplabelShape 3 + Rectangle 1outlookpersonplusprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

RE: Baltimore PHP Mailing List Daily Digest

From: Joe T.
Sent on: Tuesday, April 24, 2012 10:21 AM
I got this bit of info this morning from my Apache error log:

libpng warning: Application built with libpng[masked] but running with 1.5.5

gd-png error: cannot allocate libpng main struct

Does this mean I need to use an older version of libpng for compilation?

I don't know if this has anything to do with my problem but the output for this script:


function test ($string, $test)
    echo $string . '... ';

    if ($test)
        echo "success.\n";
        echo "fail.\n";

$token = "Testing GD!";

// Create image

$pic = ImageCreate (300, 300);

test ('Creating image', $pic);

$col2 = ImageColorAllocate ($pic, 0, 0, 100);
$col1 = ImageColorAllocate ($pic, 200, 200, 200);

// Test PNG/JPG functionality

$res1 = @ImagePNG ($pic);
$res2 = @ImageJPEG ($pic);

test ('Testing PNG output', $res1);
test ('Testing JPEG output', $res2);

// Test TrueType functionality

$ttfont = trim (`locate -n 1 .ttf`);

test ('Testing FreeType', @ImageTTFText
    ($pic, 30, 0, 10, 40, $col1, $ttfont, $token));
test ('Testing FreeType2', @ImageFTText
    ($pic, 30, 0, 10, 40, $col1, $ttfont, $token, array()));

// Test Type1 functionality

$font = @ImagePsLoadFont (trim (`locate -n 1 .pfb`));

if ($font)
    $res = @ImagePsText ($pic, $token, $font, 10, $col1, $col2, 0, 0);

test ('Testing the Type1 library', ($font && $res));

test ('Destroying image', ImageDestroy($pic));


shows some errors:


Creating image... success.

Testing PNG output... success.

Testing JPEG output... success.

Testing FreeType... fail.

Testing FreeType2... fail.


Both libraries (libpng and freetype) are compiled into PHP and are listed as enabled in phpinfo().


Subject: Re: [baltimorephp] Errors using imagecreate

From: Kevin Sours

Date: April 23,[masked]:27 PM

Reply to sender   Reply to Meetup


That's actually to be expected.   A blank file isn't a valid png.  Next step is to check your error reporting in the php.ini.  You almost certainly have an error in your script that isn't displaying. 

display_errors = 1 is the easy way, but I'd recommend configuring php error logging if it isn't (and checking the error log if it is).  I think default is to log to the apache error log file, but who knows what your install wants to do.Kevin 

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy