Jump to content

Problem with GD Library and png's


SilverJester

Recommended Posts

I'm trying to write a script that will copy images from one website (a supplier, in this case puma) and save them to the dealer's web server. I have already done this for other supplier's websites but puma uses png's instead of jpeg's and I believe that is what is causing my issues:

 

The original image looks like this:

70048924_1.png

 

The copied image some odd colors in the background like this:

pu700489%2024.png

 

Here is the code:

	$puma_image = "http://www.pumab2b.com/_static/images/styleColors/1234560002/" . str_replace(" ", "", $Item_Num) . "_1.png";
	$image = imagecreatefrompng($puma_image);

	if ($image)
	{	
		//Save image to Soccer Etc server (images folder):
		if (imagepng($image, "prod_images/" . $cur_Item['Item_Num'] . ".png", 0))
		{
			//DO some other stuff here
		}
	}

 

I just noticed after posting the original image on this forum, that it is actually transparent. I'm guessing this has something to do with my problems?

Link to comment
https://forums.phpfreaks.com/topic/235643-problem-with-gd-library-and-pngs/
Share on other sites

i dont know much about it either but you probably have to specify transparancy, and in my limited knowledge of that in images, i expect you need to set background to black as that appears to be the transparency color for the original image, hence the white/black thing. i guess from that the png you create has a default background of white.

 

so if im right you need to set background to black then set black as transparent. makes sense in my tiny mind anyways, sorry not much use of a post really

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.