Re: [PHP] Image Creation
Aaron Todd wrote: > I just wrote a little script to play around with the GD library but I am > having a problem displaying it in the browser. I have not problem at all > when I just run the script. But I was trying to make the image in a > custom > function which will return the image when its called. All I end up > getting > is a bunch of weird characters. Those weird characters ARE the image. Most likely, you finally got it right, and got rid of all the error messages, and now your image is PERFECT. However, when you have the errors in it, PHP sent out a "Cotnent-type: text/html" header before the error messages -- so you could see them as text error messages, which they were. At that time, Internet Explorer *CACHED* those headers, and is now thoroughly convinced that the URL *is* text/html, even though you are no longer sending that header. So IE is going to keep showing you the document as text/html, because IE is really stupid. If you quit IE, and start up again, and surf to the image, it should all just work. Oh, and don't do: echo ImagePNG($im); Just to: ImagePNG($im); The imageXYZ functions print out the image already, and then return 0 or -1 or something based on their success/failure to print the image. The way it works out, you're actually dumping out the image and then some bogus data at the end -- because the ImagePNG gets called FIRST, which prints out the image, and then your echo prints out the return value after all the image data went out. Most browsers probably gonna ignore that bogus extra data at the end of the image. You might want to add some error checking to your code. And use imagecreatetruecolor() to make a cleaner pie internally, even though you are converting to PNG in the end. > Here's my code: > function makepie($slice, $total){ > $height = 150; > $width = 150; > $im = ImageCreate($width, $height); > $bck = ImageColorAllocate($im, 255,255,255); > $black = ImageColorAllocate($im, 0, 0, 0); > $red = ImageColorAllocate($im, 255, 0, 0); > imagefilledellipse($im, 75, 75, 125, 125, $red); > imageellipse($im, 75, 75, 125, 125, $black); > > //Making the Slice > $pieslice = (($slice / $total) * 360) + 315; > imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black, > IMG_ARC_PIE); > > //Return > header("Content-type: image/png"); > echo ImagePNG($im); > } > > Anyone have any idea why I cant return the image? > > Thanks > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image Creation
I just wrote a little script to play around with the GD library but I am having a problem displaying it in the browser. I have not problem at all when I just run the script. But I was trying to make the image in a custom function which will return the image when its called. All I end up getting is a bunch of weird characters. Here's my code: function makepie($slice, $total){ $height = 150; $width = 150; $im = ImageCreate($width, $height); $bck = ImageColorAllocate($im, 255,255,255); $black = ImageColorAllocate($im, 0, 0, 0); $red = ImageColorAllocate($im, 255, 0, 0); imagefilledellipse($im, 75, 75, 125, 125, $red); imageellipse($im, 75, 75, 125, 125, $black); //Making the Slice $pieslice = (($slice / $total) * 360) + 315; imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black, IMG_ARC_PIE); //Return header("Content-type: image/png"); echo ImagePNG($im); } Anyone have any idea why I cant return the image? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Creation and Saving
NathanielGuy#21 wrote: Yes, I was mainly wanting to know if I needed to call it at all with what I was doing. not unless you want to create a new image (and add some part of another image to it, add some text etc) and output that. also IIRC its only available in GDlib 2.0.x and up. On Sun, 30 Jan 2005 18:45:32 +0100, Jochem Maas <[EMAIL PROTECTED]> wrote: NathanielGuy#21 wrote: Ah, thank you. after checking that the folder was there I found I had made a mistake in the path to the folder. 8_ I can believe I didnt find it before. Aside from that error, did I go about the image resizing and everything in the correct way? What is the use of imagecreatetruecolor(). Thanks for the help. imagecreatetruecolor (PHP 4 >= 4.0.6, PHP 5) imagecreatetruecolor -- Create a new true color image Description resource imagecreatetruecolor ( int x_size, int y_size ) imagecreatetruecolor() returns an image identifier representing a black image of size x_size by y_size. Example 1. Creating a new GD image stream and outputting an image. Note: This function requires GD 2.0.1 or later. Note: This function will not work with GIF file formats. See also imagedestroy() and imagecreate(). --- for a more well laided out copy of this text goto: http://nl2.php.net/imagecreatetruecolor or maybe the manual wasn't clear to you and you are seeking further clarification? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Creation and Saving
NathanielGuy#21 wrote: Ah, thank you. after checking that the folder was there I found I had made a mistake in the path to the folder. 8_ I can believe I didnt find it before. Aside from that error, did I go about the image resizing and everything in the correct way? What is the use of imagecreatetruecolor(). Thanks for the help. imagecreatetruecolor (PHP 4 >= 4.0.6, PHP 5) imagecreatetruecolor -- Create a new true color image Description resource imagecreatetruecolor ( int x_size, int y_size ) imagecreatetruecolor() returns an image identifier representing a black image of size x_size by y_size. Example 1. Creating a new GD image stream and outputting an image. Note: This function requires GD 2.0.1 or later. Note: This function will not work with GIF file formats. See also imagedestroy() and imagecreate(). --- for a more well laided out copy of this text goto: http://nl2.php.net/imagecreatetruecolor or maybe the manual wasn't clear to you and you are seeking further clarification? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Creation and Saving
Ah, thank you. after checking that the folder was there I found I had made a mistake in the path to the folder. 8_ I can believe I didnt find it before. Aside from that error, did I go about the image resizing and everything in the correct way? What is the use of imagecreatetruecolor(). Thanks for the help. --nathan On Sun, 30 Jan 2005 00:52:06 -0800, hitek <[EMAIL PROTECTED]> wrote: > Are you making sure the $_SESSION['user_sn'] folder exists before saving > the image into it? > I'm asking because I originally thought it was a permission problem but php > will tell you 'permission denied' if that was the case. > > > At 05:05 PM 1/29/2005, NathanielGuy#21 wrote: > >Hello everyone, > >I have been troubleshooting a problem with one of my scripts for a > >while now, its purpose is to allow a user to upload a file, save it to > >the server, resize it into a thumbnail, and save the thumbnail as > >well. In my script all goes well until it comes to saving the images, > >the script throws these errors: > > > >Warning: imagepng(): Unable to open > >'/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15.png' > >for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on > >line 91 > > > >Warning: imagepng(): Unable to open > >'/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15t.png' > >for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on > >line 95 > >Picture "ffq" was added to our database! The following is what we have > >generated and it is what others will see > > > >Here is the important part of the script, if more is needed i can post > >it as well. > > > > if ($mime_type == 'jpeg') { > > $new_image = imagecreatefromjpeg($_FILES['new_image']['tmp_name']); > >//Create an image refrence > > } > > elseif ($mime_type == 'png') { > > $new_image = imagecreatefrompng($_FILES['new_image']['tmp_name']); > >//Create an image refrence > > } > > elseif ($mime_type == 'gif') { > > $new_image = imagecreatefromgif($_FILES['new_image']['tmp_name']); > >//Create an image refrence > > } > > > > //Image Sizes > > list($new_image_width, $new_image_height) = > >getimagesize($_FILES['new_image']['tmp_name']);//Get img size > > if ($new_image_width > $new_image_height) {//Get thumb size > > $percent_image_size = (200 / $new_image_width); > > } > > elseif ($new_image_width < $new_image_height) { > > $percent_image_size = (200 / $new_image_height); > > } > > else { > > $percent_image_size = (200 / $new_image_height); > > } > > $new_thumb_width = ($percent_image_size * $new_image_width); > > $new_thumb_height = ($percent_image_size * $new_image_height); > > > > $new_thumb_file = imagecreatetruecolor($new_image_width, > > $new_image_height); > > imagepng($new_image, > >'/home/blacknut/public_html/picserv/picserv_mysql/pictures/' . > >strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . '.png'); > >//Copy pic to user dir as pic_id.png > > > > $new_thumb_image = imagecreatetruecolor($new_thumb_width, > >$new_thumb_height); // Create Thumb file > > imagecopyresampled($new_thumb_image, $new_image, 0, 0, 0, 0, > >$new_thumb_width, $new_thumb_height, $new_image_width, > >$new_image_height); //Copy resized to new thumb file > > imagepng($new_thumb_image, > >'/home/blacknut/public_html/picserv/picserv_mysql/pictures/' . > >strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . 't.png'); > >//Save image thumb > > > >I am very new to file/image manipulation in php so if you see any > >errors, or unnecessary code please tell me. I'm not quit sure how > >everything works, although I do have a theoretical picture of how it > >does. Any comments will be appreciated. > > > >--nathan > > > >-- > >http://www.blacknute.com/ > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- http://www.blacknute.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Creation and Saving
Are you making sure the $_SESSION['user_sn'] folder exists before saving the image into it? I'm asking because I originally thought it was a permission problem but php will tell you 'permission denied' if that was the case. At 05:05 PM 1/29/2005, NathanielGuy#21 wrote: Hello everyone, I have been troubleshooting a problem with one of my scripts for a while now, its purpose is to allow a user to upload a file, save it to the server, resize it into a thumbnail, and save the thumbnail as well. In my script all goes well until it comes to saving the images, the script throws these errors: Warning: imagepng(): Unable to open '/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15.png' for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on line 91 Warning: imagepng(): Unable to open '/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15t.png' for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on line 95 Picture "ffq" was added to our database! The following is what we have generated and it is what others will see Here is the important part of the script, if more is needed i can post it as well. if ($mime_type == 'jpeg') { $new_image = imagecreatefromjpeg($_FILES['new_image']['tmp_name']); //Create an image refrence } elseif ($mime_type == 'png') { $new_image = imagecreatefrompng($_FILES['new_image']['tmp_name']); //Create an image refrence } elseif ($mime_type == 'gif') { $new_image = imagecreatefromgif($_FILES['new_image']['tmp_name']); //Create an image refrence } //Image Sizes list($new_image_width, $new_image_height) = getimagesize($_FILES['new_image']['tmp_name']);//Get img size if ($new_image_width > $new_image_height) {//Get thumb size $percent_image_size = (200 / $new_image_width); } elseif ($new_image_width < $new_image_height) { $percent_image_size = (200 / $new_image_height); } else { $percent_image_size = (200 / $new_image_height); } $new_thumb_width = ($percent_image_size * $new_image_width); $new_thumb_height = ($percent_image_size * $new_image_height); $new_thumb_file = imagecreatetruecolor($new_image_width, $new_image_height); imagepng($new_image, '/home/blacknut/public_html/picserv/picserv_mysql/pictures/' . strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . '.png'); //Copy pic to user dir as pic_id.png $new_thumb_image = imagecreatetruecolor($new_thumb_width, $new_thumb_height); // Create Thumb file imagecopyresampled($new_thumb_image, $new_image, 0, 0, 0, 0, $new_thumb_width, $new_thumb_height, $new_image_width, $new_image_height); //Copy resized to new thumb file imagepng($new_thumb_image, '/home/blacknut/public_html/picserv/picserv_mysql/pictures/' . strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . 't.png'); //Save image thumb I am very new to file/image manipulation in php so if you see any errors, or unnecessary code please tell me. I'm not quit sure how everything works, although I do have a theoretical picture of how it does. Any comments will be appreciated. --nathan -- http://www.blacknute.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image Creation and Saving
Hello everyone, I have been troubleshooting a problem with one of my scripts for a while now, its purpose is to allow a user to upload a file, save it to the server, resize it into a thumbnail, and save the thumbnail as well. In my script all goes well until it comes to saving the images, the script throws these errors: Warning: imagepng(): Unable to open '/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15.png' for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on line 91 Warning: imagepng(): Unable to open '/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15t.png' for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on line 95 Picture "ffq" was added to our database! The following is what we have generated and it is what others will see Here is the important part of the script, if more is needed i can post it as well. if ($mime_type == 'jpeg') { $new_image = imagecreatefromjpeg($_FILES['new_image']['tmp_name']); //Create an image refrence } elseif ($mime_type == 'png') { $new_image = imagecreatefrompng($_FILES['new_image']['tmp_name']); //Create an image refrence } elseif ($mime_type == 'gif') { $new_image = imagecreatefromgif($_FILES['new_image']['tmp_name']); //Create an image refrence } //Image Sizes list($new_image_width, $new_image_height) = getimagesize($_FILES['new_image']['tmp_name']);//Get img size if ($new_image_width > $new_image_height) {//Get thumb size $percent_image_size = (200 / $new_image_width); } elseif ($new_image_width < $new_image_height) { $percent_image_size = (200 / $new_image_height); } else { $percent_image_size = (200 / $new_image_height); } $new_thumb_width = ($percent_image_size * $new_image_width); $new_thumb_height = ($percent_image_size * $new_image_height); $new_thumb_file = imagecreatetruecolor($new_image_width, $new_image_height); imagepng($new_image, '/home/blacknut/public_html/picserv/picserv_mysql/pictures/' . strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . '.png'); //Copy pic to user dir as pic_id.png $new_thumb_image = imagecreatetruecolor($new_thumb_width, $new_thumb_height); // Create Thumb file imagecopyresampled($new_thumb_image, $new_image, 0, 0, 0, 0, $new_thumb_width, $new_thumb_height, $new_image_width, $new_image_height); //Copy resized to new thumb file imagepng($new_thumb_image, '/home/blacknut/public_html/picserv/picserv_mysql/pictures/' . strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . 't.png'); //Save image thumb I am very new to file/image manipulation in php so if you see any errors, or unnecessary code please tell me. I'm not quit sure how everything works, although I do have a theoretical picture of how it does. Any comments will be appreciated. --nathan -- http://www.blacknute.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image creation
Dear all, Thanks Kilimajer's help and I can finally build-in the GD library. But when i use the imagecreate function for jpeg, don't know why there are some unknown wordings appears. Sth like the following: 1oACEEEO¡ÑOUUaaceeeno Don't know what's happening, I just use simple function (e.g. Imagecreate,Imagejpeg) to test it. Thx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image creation error
General builds of the GD library don't contain gif support. Visit the GD site to see what they say about gif support. If you're building a graph then use png; if an image use jpg. Hugh - Original Message - From: "Michael P. Carel" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, February 17, 2003 6:51 PM Subject: Re: [PHP] image creation error > i've already compiled my PHP4 with imagejpeg support but now im loosing my > imagegif function. Image jpeg function is now working but for the gif im > receiving this error: > Fatal error: Call to undefined function: imagegif() > > Here's my php info after my re-compilation : > > Configure Command './configure' '--with-mysql' > '--with-apache=../apache_1.3.24' '--with-gd' > '--with-jpeg-dir=/php-4.3.0/ext/gd/libgd' '--with-zlib' > GD Support enabled > GD Version bundled (2.0 compatible) > GIF Read Support enabled > JPG Support enabled > PNG Support enabled > WBMP Support enabled > > > Any idea why? > > > Mike > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image creation error
On Tuesday 18 February 2003 10:51, Michael P. Carel wrote: > i've already compiled my PHP4 with imagejpeg support but now im loosing my > imagegif function. Image jpeg function is now working but for the gif im > receiving this error: > Fatal error: Call to undefined function: imagegif() > > Here's my php info after my re-compilation : > > Configure Command './configure' '--with-mysql' > '--with-apache=../apache_1.3.24' '--with-gd' > '--with-jpeg-dir=/php-4.3.0/ext/gd/libgd' '--with-zlib' > GD Support enabled > GD Version bundled (2.0 compatible) > GIF Read Support enabled > JPG Support enabled > PNG Support enabled > WBMP Support enabled > > > Any idea why? You need GIF write support in the GD library, which isn't officially supported anymore. Google for non-official GD library with GIF support. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Civilization is fun! Anyway, it keeps me busy!! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image creation error
i've already compiled my PHP4 with imagejpeg support but now im loosing my imagegif function. Image jpeg function is now working but for the gif im receiving this error: Fatal error: Call to undefined function: imagegif() Here's my php info after my re-compilation : Configure Command './configure' '--with-mysql' '--with-apache=../apache_1.3.24' '--with-gd' '--with-jpeg-dir=/php-4.3.0/ext/gd/libgd' '--with-zlib' GD Support enabled GD Version bundled (2.0 compatible) GIF Read Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled Any idea why? Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image creation error
On Friday 14 February 2003 16:15, Michael P. Carel wrote: > i've already installed gd but still recieving > Fatal error: Call to undefined function: > imagecreatefromjpeg() . You need to configure --with-jpeg-dir. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* "Be *excellent* to each other." -- Bill, or Ted, in Bill and Ted's Excellent Adventure */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image creation error
i've already installed gd but still recieving Fatal error: Call to undefined function: imagecreatefromjpeg() . - Original Message - From: "Michael P. Carel" <[EMAIL PROTECTED]> To: "Kevin Waterson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, February 14, 2003 3:45 PM Subject: Re: [PHP] image creation error > i've recompile my php4.3 in redhat with > ./configure --with-mysql --with-apache=../apache_1.3.x --with-gd --with-zlib > > and i receive this error upon make > > make: *** Warning: File `libphp4.la' has modification time in the future > (2003-0 > 2-14 16:04:12 > 2003-02-14 15:47:10) > make: Nothing to be done for `all'. > make: *** Warning: Clock skew detected. Your build may be incomplete. > > > What should be the problem? > > > - Original Message - > From: "Kevin Waterson" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, February 14, 2003 3:07 PM > Subject: Re: [PHP] image creation error > > > > This one time, at band camp, > > "Michael P. Carel" <[EMAIL PROTECTED]> wrote: > > > > > Hi to all, > > > > > > Im receiving a Fatal error: Call to undefined function: > > > imagecreatefromjpeg() . > > > > You need to install gd > > > > in your config line add > > > > --with-gd > > > > Kevin > > > > -- > > __ > > (_ \ > > _) ) > > | / / _ ) / _ | / ___) / _ ) > > | | ( (/ / ( ( | |( (___ ( (/ / > > |_| \) \_||_| \) \) > > Kevin Waterson > > Port Macquarie, Australia > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image creation error
i've recompile my php4.3 in redhat with ./configure --with-mysql --with-apache=../apache_1.3.x --with-gd --with-zlib and i receive this error upon make make: *** Warning: File `libphp4.la' has modification time in the future (2003-0 2-14 16:04:12 > 2003-02-14 15:47:10) make: Nothing to be done for `all'. make: *** Warning: Clock skew detected. Your build may be incomplete. What should be the problem? - Original Message - From: "Kevin Waterson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, February 14, 2003 3:07 PM Subject: Re: [PHP] image creation error > This one time, at band camp, > "Michael P. Carel" <[EMAIL PROTECTED]> wrote: > > > Hi to all, > > > > Im receiving a Fatal error: Call to undefined function: > > imagecreatefromjpeg() . > > You need to install gd > > in your config line add > > --with-gd > > Kevin > > -- > __ > (_ \ > _) ) > | / / _ ) / _ | / ___) / _ ) > | | ( (/ / ( ( | |( (___ ( (/ / > |_| \) \_||_| \) \) > Kevin Waterson > Port Macquarie, Australia > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image creation error
This one time, at band camp, "Michael P. Carel" <[EMAIL PROTECTED]> wrote: > Hi to all, > > Im receiving a Fatal error: Call to undefined function: > imagecreatefromjpeg() . You need to install gd in your config line add --with-gd Kevin -- __ (_ \ _) ) | / / _ ) / _ | / ___) / _ ) | | ( (/ / ( ( | |( (___ ( (/ / |_| \) \_||_| \) \) Kevin Waterson Port Macquarie, Australia -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] image creation error
Hi to all, Im receiving a Fatal error: Call to undefined function: imagecreatefromjpeg() . Do i need to recompile PHP? mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] image creation class
Maybe there went something wrong with the attachment in my last mail. This is my second try bring the class for creating thumbs to you. class constructor ***parameters string pic -> full pic name, including the path (absolute or relative) string format -> the format of the input file, be sure that GDLib handle it! destroy() -> free the resources bool create() -> initialize the handling of the pic, thats not required after the constructor but could be required after some method calls like setPicName($pic), i.e. setPicName(string pic) -> change the handled pic, the class require a call to create() after this ***parameters string pic -> full pic name, including the path (absolute or relative) string getPicName() -> returns the name of the handled pic setThumbDimension(float pctg) -> initialize the dimensions of the default thumbnail ***parameters float pctg -> float number (0 return as referenced parameters the default dimension on the thumbnail setPicFormat(string format) -> set a new output format for the loaded pic, require a call to create() after this ***parameters string format -> the format of the input file, be sure that GDLib handle it! string getPicFormat() -> returns the format of the output thumb() -> output the default thumbnail full() -> output the original image view(float width, float height) -> output a thumbnail, the dimension is specified in the parameters of the methodù ***parameters float width -> width of the output pic float height-> height of the output pic */ class DynaPic { var $m_sPicName; //file name with path var $m_sFormat; //file format, check m_asAllowedFormat var $m_hPic; //image handle var $m_bHandled; //flag to check if the pic is well loaded var $m_nThumbX; //width of the thumbnail var $m_nThumbY; //height of the thumbnail //possible pic formats var $m_asAllowedFormat= array("GIF","PNG","JPEG"); //and related headers var $m_aHeaders = array("GIF"=>"Content-type: image/gif","PNG"=>"Content-type: image/png","JPEG"=>"Content-type: image/jpeg"); function DynaPic() { die("Constructor requires parameters: string pic_path, string "); } function DynaPic($pic,$format) { $this->m_sFormat = strtoupper($format); //check if valid format if(!in_array($this->m_sFormat,$this->m_asAllowedFormat)) { die("Invalid format: ".stripslashes(htmlentities($this->m_sFormat))); } //initialize $this->m_sPicName=$pic; //thumb default resize 50% $this->setThumbDimension(0.5); if(!$this->create()) die("Unable to create ".stripslashes(htmlentities($this->m_sPicName))." as ".stripslashes(htmlentities($this->m_sFormat))); } function destroy() { if($this->m_bHandled) { imagedestroy($this->m_hPic); $this->m_bHandled=false; } } function create() { $this->destroy(); eval("\$this->m_hPic=@imagecreatefrom".$this->m_sFormat."('".$this->m_sPicNa me."');"); //check if init succeded if(!$this->m_hPic) { $this->m_bHandled=false; return false; } else { $this->m_bHandled=true; return true; } } function setPicName($pic) { $this->m_sPicName=$pic; $this->m_bHandled=false; } function getPicName() { return $this->m_sPicName; } function setThumbDimension($pctg) { if($pctg<=0 || $pctg>1) die("Not a valid resize factor"); $size = GetImageSize($this->m_sPicName); $this->m_nThumbX=$size[0]*$pctg; $this->m_nThumbY=$size[1]*$p
RE: [PHP] image creation to file
Hi You have to make sure that the user that your web server is running as has permission to write where you want to create the file. Tom At 12:56 PM 7/03/2002, Craig Westerman wrote: >Hi Tom, > >At first it didn't work. I had to create a blank png image in Photoshop and >uploaded it. I then changed file permissions and then the image creation >worked. Is there a way to write to test.png when it doesn't already exist >and file permissions are set? > >Thanks for your help. > >Craig ><> >[EMAIL PROTECTED] > > > >Hi >use ImagePNG($im,"test.png") > >Tom > >At 12:17 PM 7/03/2002, Craig Westerman wrote: > >The following creates a red rectangle png image > > > > >Header("Content-Type: image/png"); > >$im = ImageCreate(500, 75); > >$red = ImageColorAllocate($im, 255, 0, 0); > >ImageFill($im, 100, 100, $red); > >ImagePNG($im); > >?> > > > > > >This sends created image to browser > >ImagePNG($im); > > > > > >How would I save this image as test.png to file to be hard coded in static > >web pages? > > > >Thanks > > > >Craig ><> > >[EMAIL PROTECTED] > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image creation to file
An alternative is to put the code into makeImage.php and then call it directly from your HTML page with your whenever you want that image displayed. Jim. "Tom Rogers" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi > use ImagePNG($im,"test.png") > > Tom > > At 12:17 PM 7/03/2002, Craig Westerman wrote: > >The following creates a red rectangle png image > > > > >Header("Content-Type: image/png"); > >$im = ImageCreate(500, 75); > >$red = ImageColorAllocate($im, 255, 0, 0); > >ImageFill($im, 100, 100, $red); > >ImagePNG($im); > >?> > > > > > >This sends created image to browser > >ImagePNG($im); > > > > > >How would I save this image as test.png to file to be hard coded in static > >web pages? > > > >Thanks > > > >Craig ><> > >[EMAIL PROTECTED] > > > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] image creation to file
Hi Tom, At first it didn't work. I had to create a blank png image in Photoshop and uploaded it. I then changed file permissions and then the image creation worked. Is there a way to write to test.png when it doesn't already exist and file permissions are set? Thanks for your help. Craig ><> [EMAIL PROTECTED] Hi use ImagePNG($im,"test.png") Tom At 12:17 PM 7/03/2002, Craig Westerman wrote: >The following creates a red rectangle png image > >Header("Content-Type: image/png"); >$im = ImageCreate(500, 75); >$red = ImageColorAllocate($im, 255, 0, 0); >ImageFill($im, 100, 100, $red); >ImagePNG($im); >?> > > >This sends created image to browser >ImagePNG($im); > > >How would I save this image as test.png to file to be hard coded in static >web pages? > >Thanks > >Craig ><> >[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image creation to file
Hi use ImagePNG($im,"test.png") Tom At 12:17 PM 7/03/2002, Craig Westerman wrote: >The following creates a red rectangle png image > >Header("Content-Type: image/png"); >$im = ImageCreate(500, 75); >$red = ImageColorAllocate($im, 255, 0, 0); >ImageFill($im, 100, 100, $red); >ImagePNG($im); >?> > > >This sends created image to browser >ImagePNG($im); > > >How would I save this image as test.png to file to be hard coded in static >web pages? > >Thanks > >Craig ><> >[EMAIL PROTECTED] > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] image creation to file
The following creates a red rectangle png image This sends created image to browser ImagePNG($im); How would I save this image as test.png to file to be hard coded in static web pages? Thanks Craig ><> [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD/PHP Image Creation - combining GIFs
Hi All, I need to automatically create a large GIF image made up of numerous smaller GIF/JPG files. The list of images (either GIF or JPG) is taken off a MySQL database and at the moment, I create a HTML table (5 columns, up to 20 rows), view it in my browser, manually dump it to the screen and then edit it in a image program to the right size. Then I save it as a transparent GIF and use a server-side image map to extract the right filename when a user clicks on it. (I'm not willing to move to a system where each individual image is loaded individually!) This is getting a little too time-consuming, so I want PHP to do it for me ;-) I only need it to generate the new images when they are added, so speed is not an issue. Has anyone created something like this, or does anyone have any tips on how to do it? I'm looking into ImageMagick right now (looking through the archives). The only thing is, I need to do this on my Win98 system.. Thanks in advance, John -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]