944,155 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 703
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Nov 7th, 2009
0

png image croping problem

Expand 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
Similar Threads
Reputation Points: 12
Solved Threads: 27
Junior Poster
rajabhaskar525 is offline Offline
179 posts
since Nov 2009
Nov 7th, 2009
0
Re: png image croping problem
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
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Nov 7th, 2009
0
Re: png image croping problem
k. its working . but this function not supporting .bmp image files.
"
PHP Syntax (Toggle Plain Text)
  1. imagewbmp($bgim_new, $bgth_file_name,9);
" and also i put 100 like this
PHP Syntax (Toggle Plain Text)
  1. imagewbmp($bgim_new, $bgth_file_name,100);
still not working
Reputation Points: 12
Solved Threads: 27
Junior Poster
rajabhaskar525 is offline Offline
179 posts
since Nov 2009
Nov 7th, 2009
2
Re: png image croping problem
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.
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007
Nov 9th, 2009
0

imagepng() works for .png format only

k. its working . but this function not supporting .bmp image files.
"
PHP Syntax (Toggle Plain Text)
  1. imagewbmp($bgim_new, $bgth_file_name,9);
" and also i put 100 like this
PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Nov 19th, 2009
0
Re: png image croping problem
Click to Expand / Collapse  Quote originally posted by network18 ...
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?
Reputation Points: 12
Solved Threads: 27
Junior Poster
rajabhaskar525 is offline Offline
179 posts
since Nov 2009
Nov 19th, 2009
0
Re: png image croping problem
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.
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Nov 19th, 2009
0
Re: png image croping problem
Click to Expand / Collapse  Quote originally posted by network18 ...
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!!
Reputation Points: 12
Solved Threads: 27
Junior Poster
rajabhaskar525 is offline Offline
179 posts
since Nov 2009
Nov 19th, 2009
0
Re: png image croping problem
Click to Expand / Collapse  Quote originally posted by network18 ...
imagewbmp() sets the foreground color.
Look for setImageBackgroundColor() function of the Imagick.
i didn't catch u. can expain clearly.
PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 12
Solved Threads: 27
Junior Poster
rajabhaskar525 is offline Offline
179 posts
since Nov 2009
Nov 19th, 2009
0
Re: png image croping problem
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; Nov 19th, 2009 at 10:28 am. Reason: Typos
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Passing variable as a link
Next Thread in PHP Forum Timeline: chechbox validations





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC