png image croping problem

Reply

Join Date: Nov 2009
Posts: 93
Reputation: rajabhaskar525 is an unknown quantity at this point 
Solved Threads: 6
rajabhaskar525 rajabhaskar525 is offline Offline
Junior Poster in Training

png image croping problem

 
0
  #1
Nov 7th, 2009
hi all. i want to crop png image.
when i am croping the png image i got "Fatal error: imagepng() [<a href='function.imagepng'>function.imagepng</a>]: 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
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 557
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 64
network18 network18 is offline Offline
Posting Pro
 
0
  #2
Nov 7th, 2009
Originally Posted by rajabhaskar525 View Post
hi all. i want to crop png image.
when i am croping the png image i got "Fatal error: imagepng() [<a href='function.imagepng'>function.imagepng</a>]: 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
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 93
Reputation: rajabhaskar525 is an unknown quantity at this point 
Solved Threads: 6
rajabhaskar525 rajabhaskar525 is offline Offline
Junior Poster in Training
 
0
  #3
Nov 7th, 2009
k. its working . but this function not supporting .bmp image files.
"
  1. imagewbmp($bgim_new, $bgth_file_name,9);
" and also i put 100 like this
  1. imagewbmp($bgim_new, $bgth_file_name,100);
still not working
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 455
Reputation: Atli is on a distinguished road 
Solved Threads: 56
Atli's Avatar
Atli Atli is offline Offline
Posting Pro in Training
 
2
  #4
Nov 7th, 2009
Hey.

If you are having problems with functions, look them up in the manual.

The third parameter of the imagewbmp function is not the same as the third parameter for the png function. The manual explains the difference. Even gives examples.
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 557
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 64
network18 network18 is offline Offline
Posting Pro

imagepng() works for .png format only

 
0
  #5
Nov 9th, 2009
Originally Posted by rajabhaskar525 View Post
k. its working . but this function not supporting .bmp image files.
"
  1. imagewbmp($bgim_new, $bgth_file_name,9);
" and also i put 100 like this
  1. 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.
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 93
Reputation: rajabhaskar525 is an unknown quantity at this point 
Solved Threads: 6
rajabhaskar525 rajabhaskar525 is offline Offline
Junior Poster in Training
 
0
  #6
33 Days Ago
Originally Posted by network18 View Post
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
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?
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 557
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 64
network18 network18 is offline Offline
Posting Pro
 
0
  #7
33 Days Ago
Originally Posted by rajabhaskar525 View Post
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.
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 93
Reputation: rajabhaskar525 is an unknown quantity at this point 
Solved Threads: 6
rajabhaskar525 rajabhaskar525 is offline Offline
Junior Poster in Training
 
0
  #8
33 Days Ago
Originally Posted by network18 View Post
imagewbmp() sets the foreground color.
Look for setImageBackgroundColor() function of the Imagick.
this is also one of the problem, before that i struck at imagepng(); method , i am getting croped png with black background . give me idea!!
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 93
Reputation: rajabhaskar525 is an unknown quantity at this point 
Solved Threads: 6
rajabhaskar525 rajabhaskar525 is offline Offline
Junior Poster in Training
 
0
  #9
33 Days Ago
Originally Posted by network18 View Post
imagewbmp() sets the foreground color.
Look for setImageBackgroundColor() function of the Imagick.
i didn't catch u. can expain clearly.
  1. $bgim_new = imagecreatetruecolor($bgth_width,$bgth_height);
  2. imageantialias($bgim_new,true);
  3. $bgth_file_name = "productimages/140X150/$Attachments1";
  4. imagecopyresampled($bgim_new,$bgim_old,0,0,0,0,$bgth_width,$bgth_height, $bgimage_attribs[0], $bgimage_attribs[1]);
  5. if(($filetype1=='image/png') || ($filetype1=='image/x-png') ||($filetype1=='image/PNG') || ($filetype1=='image/X-PNG'))
  6. {
  7. imagepng($bgim_new,$bgth_file_name,9);
  8. }
  9. else if(($filetype1 == "image/bmp") || ($filetype1 == "image/BMP"))
  10. {
  11. imagewbmp($bgim_new, $bgth_file_name,$bgim_new);
  12. }
this my code. what wrong with my code. help me.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 455
Reputation: Atli is on a distinguished road 
Solved Threads: 56
Atli's Avatar
Atli Atli is offline Offline
Posting Pro in Training
 
0
  #10
33 Days Ago
You are using the imagewbmp function incorrectly.

The third parameter of the imagewbmp function sets the foreground color of the image to a color created by the imagecolorallocate function.

Look at the third example in the manual. It shows how to correctly use the third parameter.
Last edited by Atli; 33 Days Ago at 10:28 am. Reason: Typos
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 417 | Replies: 14
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC