Trying to get an image to work with GD

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tictran
Forum Newbie
Posts: 2
Joined: Mon Aug 02, 2010 7:18 pm

Trying to get an image to work with GD

Post by tictran »

I have a simple image to work on and am stalled at the basics. I read the image in and dump it out, and it turns virtually all black. The image is a simple chart in black and white, like a seating chart. I say virtually because there is a small gray section in the image and that comes out OK, that's how I'm able to conclude that the image is actually there.

I've tried the following code, it works exactly the same with or without the imagecolorallocate statement (also regardless of the values I put in for the colors). I should mention that if I just display the URL of the input png file, it displays correctly in both Firefox and IE, and this problem occurs in both Firefox and IE.

<?php
header('Content-type: image/png');
$imgname = "filename.png";
$im = imagecreatefrompng($imgname);
$background = imagecolorallocate($im,255,255,255);
imagepng($im);
imagedestroy($im);
?>

So I guess there is something wrong with the original image that GD is particularly picky about? I should mention that the original image is in SVG and converted to png with an ubuntu program called "rasterize".

Thanks for any help you can offer!
tictran
Forum Newbie
Posts: 2
Joined: Mon Aug 02, 2010 7:18 pm

Re: Trying to get an image to work with GD

Post by tictran »

Well darn if I didn't figure out how to fix it myself. I just played around with the background option to rasterizer (which I erroneously called "rasterize" in my earlier post) and that fixed it. Appears that not setting the background to that program is a problem.
Post Reply