hi all. i want to crop png image.
when i am croping the png image i got "Fatal error: imagepng() [function.imagepng]: gd-png: fatal libpng error: zlib error in C:\wamp\www\taslan\admin\products.php on line 120" error message. at line no 120 shows imagepng($bgim_new,$bgth_file_name,100); this function
The 3rd optional parameter to the imagepng() is called the quality and it specifies the compression level used.
It should have the value from 0 to 9 only, you used the much higher value for it :)
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
k. its working . but this function not supporting .bmp image files.
"
imagewbmp($bgim_new, $bgth_file_name,9);
" and also i put 100 like this
imagewbmp($bgim_new, $bgth_file_name,100);
still not working
Its very natural if imagepng() doesn't suppport .bmp images.
and the imagewbmp() is not having the same parameters as like imagepng().
The 1st parameter to imagewbmp() is the image resource , 2nd is the file path and the 3rd is the forground color to be specified as the int value.The default value to it that of the black color.
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
hello,
i am facing another problem with this. i used values between '0' to '9' then image background color is changing like black. what is alternative for this?
imagewbmp() sets the foreground color.
Look for setImageBackgroundColor() function of the Imagick.
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
i get black background for the imagepng();. what hpnd with my code.
line11 the imagewbmp() functions takes the foreground color as the third parameter.
And the background color to the image after the imagepng() function -
if(($filetype1=='image/png') || ($filetype1=='image/x-png') ||($filetype1=='image/PNG') || ($filetype1=='image/X-PNG'))
{
imagepng($bgim_new,$bgth_file_name,9);
//set the background color to your choice, paramters are int values of red,green and blue
imagecolorallocate($bgim_new,$red,$green,$blue);
}
else if(($filetype1 == "image/bmp") || ($filetype1 == "image/BMP"))
{
//set the foreground color here
$foreground = '';
imagewbmp($bgim_new, $bgth_file_name,$foreground);
}
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76