[PHP] php gd extension with cPanel
Hello, I'm hoping there's an easy fix for this. I've got a centos server machine 6.4 I believe with cPanel running on it. I need to enable the gd extension, both the gd and gd-devel rpm packages are installed, but php is not, that is showing up in a package list. It is however installed as it's gone through cPanel. It does not however have the php-gd extension. I am wondering if there's an easy way to get this extension working? I do not want to have to recompile the whole php to do this. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gd Graphics Library Question (EXIF)
On Saturday, 30 April 2011 at 03:32, Mitch wrote: I was wondering about that. Since I am not actually hosting my ISP would > have to have it loaded (or compiled into their PHP implementation), right? You may be able to use http://php.net/dl to load the extension (you'll need to build it to be compatible with your host and then upload it) but it's highly unlikely they'll have the dl function enabled. Your best bet is to ask them to add it to their environment. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ > On 4/29/2011 9:26 AM, Stuart Dallas wrote: > > On Friday, 29 April 2011 at 03:33, Mitch wrote: > > I have written a lightweight, easy to use photo album "system" in > > > HTML/PHP/MySQL.In addition to the Photo Album side I have written a > > > series of Admin Utilities to manage it with. One of the administrative > > > utilities uploads photos from my local drive, resizes them to be more > > > efficient on disk space, creates thumbnails and populates the database > > > with as much "default" data as can be deduced. > > > > > > After all of this was written, I decided to see if I could pull EXIF > > > data to supply some of the technical data for the DB. To my surprise, > > > the only EXIF data in the JPEG files was data in the File, Computed and > > > Comments sections. > > > > > > Why don't the gd utilities retain the original EXIF data? Is there any > > > way to do so? I use the following gd utilities to resize and create the > > > new JPEG image files: > > > > > > imagecreatefromjpeg > > > imagesx > > > imagesy > > > imagercreatetruecolor > > > imagecopyresized > > > imagejpeg > > > > This is a known shortcoming of the GD library. You won't have that issue > > with ImageMagick: http://php.net/book.imagick > > > > -Stuart > > > -- > 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] gd Graphics Library Question (EXIF)
I was wondering about that. Since I am not actually hosting my ISP would have to have it loaded (or compiled into their PHP implementation), right? I'll have to do some legwork with my ISP and ImageMagic On 4/29/2011 9:26 AM, Stuart Dallas wrote: On Friday, 29 April 2011 at 03:33, Mitch wrote: I have written a lightweight, easy to use photo album "system" in HTML/PHP/MySQL.In addition to the Photo Album side I have written a series of Admin Utilities to manage it with. One of the administrative utilities uploads photos from my local drive, resizes them to be more efficient on disk space, creates thumbnails and populates the database with as much "default" data as can be deduced. After all of this was written, I decided to see if I could pull EXIF data to supply some of the technical data for the DB. To my surprise, the only EXIF data in the JPEG files was data in the File, Computed and Comments sections. Why don't the gd utilities retain the original EXIF data? Is there any way to do so? I use the following gd utilities to resize and create the new JPEG image files: imagecreatefromjpeg imagesx imagesy imagercreatetruecolor imagecopyresized imagejpeg This is a known shortcoming of the GD library. You won't have that issue with ImageMagick: http://php.net/book.imagick -Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gd Graphics Library Question (EXIF)
On Friday, 29 April 2011 at 03:33, Mitch wrote: I have written a lightweight, easy to use photo album "system" in > HTML/PHP/MySQL.In addition to the Photo Album side I have written a > series of Admin Utilities to manage it with. One of the administrative > utilities uploads photos from my local drive, resizes them to be more > efficient on disk space, creates thumbnails and populates the database > with as much "default" data as can be deduced. > > After all of this was written, I decided to see if I could pull EXIF > data to supply some of the technical data for the DB. To my surprise, > the only EXIF data in the JPEG files was data in the File, Computed and > Comments sections. > > Why don't the gd utilities retain the original EXIF data? Is there any > way to do so? I use the following gd utilities to resize and create the > new JPEG image files: > > imagecreatefromjpeg > imagesx > imagesy > imagercreatetruecolor > imagecopyresized > imagejpeg This is a known shortcoming of the GD library. You won't have that issue with ImageMagick: http://php.net/book.imagick -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gd Graphics Library Question (EXIF)
Hi Mitch, you could try with http://www.php.net/manual/en/function.exif-read-data.php I did a test with image jpg and this was the result: FILE . FileName: bruce_lee_black_white.jpg FILE . FileDateTime: 1304086298 FILE . FileSize: 33464 FILE . FileType: 2 FILE . MimeType: image/jpeg FILE . SectionsFound: COMMENT COMPUTED . html: width="353" height="450" COMPUTED . Height: 450 COMPUTED . Width: 353 COMPUTED . IsColor: 1 COMMENT . 0: LEAD Technologies Inc. V1.01 Anyway taking account *EXIF headers tend to be present in JPEG/TIFF images generated by digital cameras, but unfortunately each digital camera maker has a different idea of how to actually tag their images, so you can't always rely on a specific Exif header being present. * Regards. Gerardo. On Thu, Apr 28, 2011 at 11:33 PM, Mitch wrote: > I have written a lightweight, easy to use photo album "system" in > HTML/PHP/MySQL.In addition to the Photo Album side I have written a series > of Admin Utilities to manage it with. One of the administrative utilities > uploads photos from my local drive, resizes them to be more efficient on > disk space, creates thumbnails and populates the database with as much > "default" data as can be deduced. > > After all of this was written, I decided to see if I could pull EXIF data > to supply some of the technical data for the DB. To my surprise, the only > EXIF data in the JPEG files was data in the File, Computed and Comments > sections. > > Why don't the gd utilities retain the original EXIF data? Is there any way > to do so? I use the following gd utilities to resize and create the new JPEG > image files: > > imagecreatefromjpeg > imagesx > imagesy > imagercreatetruecolor > imagecopyresized > imagejpeg > > Thanks in advance, > Mitch > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Gerardo Benitez - www.webseficientes.com.ar Diseño web, programación, Seo
[PHP] gd Graphics Library Question (EXIF)
I have written a lightweight, easy to use photo album "system" in HTML/PHP/MySQL.In addition to the Photo Album side I have written a series of Admin Utilities to manage it with. One of the administrative utilities uploads photos from my local drive, resizes them to be more efficient on disk space, creates thumbnails and populates the database with as much "default" data as can be deduced. After all of this was written, I decided to see if I could pull EXIF data to supply some of the technical data for the DB. To my surprise, the only EXIF data in the JPEG files was data in the File, Computed and Comments sections. Why don't the gd utilities retain the original EXIF data? Is there any way to do so? I use the following gd utilities to resize and create the new JPEG image files: imagecreatefromjpeg imagesx imagesy imagercreatetruecolor imagecopyresized imagejpeg Thanks in advance, Mitch -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD Watermark Question
On 19 September 2010 16:05, tedd wrote: > At 6:03 PM -0400 9/17/10, Gary wrote: >> >> Is there a way to insert a watermark on an image as it is being uploaded >> to >> the image file, then removed when it is called from a database to be >> viewed >> on a website? >> >> The rational behind this is I have a photographers site I am doing, and I >> am >> limiting the size of the images somewhat to reduce pilferage and I would >> like to be able to show the images a little larger, hence with a bit more >> clarity and detail. >> >> Thanks for your input. >> >> Gary > > Gary: > > Don't complicate this process more than necessary. > > Simply upload the image file normally and store it in the file system OR the > database. > > When you want to show the image as a thumbnail, then show it. Here's the > code: > > http://webbytedd.com/b/thumb/ > > If you want to show it with a watermark, then show that. Again, here's the > code: > > http://webbytedd.com/b/watermark/ > > If you want to show the image as a thumbnail with a watermark, then combine > the two routines. I'll leave that to you. > You're generating the thumbnail on every request. Just generate it once and serve the thumbnail as a file (there's no reason why you would need to invoke php to show a thumbnail of an image). Regards Peter -- WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind BeWelcome/Couchsurfing: Fake51 Twitter: http://twitter.com/kafe15 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD Watermark Question
At 6:03 PM -0400 9/17/10, Gary wrote: Is there a way to insert a watermark on an image as it is being uploaded to the image file, then removed when it is called from a database to be viewed on a website? The rational behind this is I have a photographers site I am doing, and I am limiting the size of the images somewhat to reduce pilferage and I would like to be able to show the images a little larger, hence with a bit more clarity and detail. Thanks for your input. Gary Gary: Don't complicate this process more than necessary. Simply upload the image file normally and store it in the file system OR the database. When you want to show the image as a thumbnail, then show it. Here's the code: http://webbytedd.com/b/thumb/ If you want to show it with a watermark, then show that. Again, here's the code: http://webbytedd.com/b/watermark/ If you want to show the image as a thumbnail with a watermark, then combine the two routines. I'll leave that to you. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD Watermark Question
On Fri, 2010-09-17 at 18:03 -0400, Gary wrote: > Is there a way to insert a watermark on an image as it is being uploaded to > the image file, then removed when it is called from a database to be viewed > on a website? > > The rational behind this is I have a photographers site I am doing, and I am > limiting the size of the images somewhat to reduce pilferage and I would > like to be able to show the images a little larger, hence with a bit more > clarity and detail. > > Thanks for your input. > > Gary > > > > __ Information from ESET Smart Security, version of virus signature > database 5458 (20100917) __ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > > > So where does the watermark get shown, because from what I can gather from your description, it only exists on the image with the DB... Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] GD Watermark Question
Is there a way to insert a watermark on an image as it is being uploaded to the image file, then removed when it is called from a database to be viewed on a website? The rational behind this is I have a photographers site I am doing, and I am limiting the size of the images somewhat to reduce pilferage and I would like to be able to show the images a little larger, hence with a bit more clarity and detail. Thanks for your input. Gary __ Information from ESET Smart Security, version of virus signature database 5458 (20100917) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD - import a PNG image and make transparant
Hi Ash, Thanks for your suggestion. I think this is where my confusion is. I understand how to use imagecolorallocatealpha() to for example create a 50% transparant colour, and apply it to a new rectangle for example. I dont understand how to "apply" it to a new source image, for example $src = imagecreatefrompng('test.png'); // Something here (maybe imagecolorallocatealpha()) to make this 50% transparent- either on its own, or make it 50% transparent as part of a copy onto a new image I had thought that imagecopymerge would help me with this, but it seems not. I'm currently looking through Karl's example to see if I can work it out, but if anyone can point out a super-simple way of achieving the pseudo-code above, i'd be very grateful! Cheers, Alex On Thu, May 13, 2010 at 1:34 AM, Ashley Sheridan wrote: > On Thu, 2010-05-13 at 00:12 +0100, Alex Davies wrote: > > Hi, > > I am trying to import a PNG image from disk, place it on top of a > transparant image created in GD and output it to the browser. In the case of > a low opacity setting, I would expect to see the background colour from the > HTML page. > > If I set the opacity to 0, everything works - I end up with a transparant > image. > > However, if I set it for any value >0 (even 1) instead of a > very-faint-image the whole thing goes black. As the opacity level goes up > from 0, the amount of black reduces and the amount of imported image > increases - but this is not what I want. > > I am using this code: > > $src = imagecreatefrompng('test.png'); > $img_width = imagesx($src); > $img_height = imagesy($src); > > // Create trans image > $dest = imagecreatetruecolor($img_width, $img_height); > //imagesavealpha($dest, true); // This has no effect it appears > $trans_colour = imagecolorallocatealpha($dest, 0, 255, 0, 128); > > // Make the background transparent > imagecolortransparent($dest, $trans_colour); > //imagefill($dest, 0, 0, $trans_colour); // This does not work > > // Merge src on top of dest, with opacity of 1 in this case > imagecopymerge($dest, $src, 0, 0, 0, 0, $img_width, $img_height, 1); > > // Output and free from memory > header('Content-Type: image/png'); > imagepng($dest); > ?> > > The images that this outputs, at opacity levels 0,1 and 80 on a red and > green background (screenshots of a HTML page) can be downloaded > fromhttp://www.box.net/shared/h9zn4tjgro > > Any help appreciated! > > Cheers, > > Alex > > > How exactly are you setting the opacity for the image? The traditional way > is to use imagecolorallocatealpha() on the source. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > -- Alex Davies This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender immediately by e-mail and delete this e-mail permanently.
Re: [PHP] GD - import a PNG image and make transparant
Hey tedd, Sorry bout that.. here you go. http://designdrumm.com/upload_images_test.zip Karl On May 13, 2010, at 9:06 AM, tedd wrote: At 6:40 PM -0500 5/12/10, Karl DeSaulniers wrote: Hi Alex, I have a php file I made just a few months ago. It takes a gif, jpeg or png of any size and sizes it proportionately to a specified size and then outputs a png. If the image is a transparent png or transparent gif, it will still hold the transparency. This is just a test page and it tested ok for me, but it is my first one. I also tested it on PHP 5. Dont know about compatibility to older versions. Knowing that, here you go. http://designdrumm.com/upload_images_test.php.zip HTH, Karl Bad link. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD - import a PNG image and make transparant
At 6:40 PM -0500 5/12/10, Karl DeSaulniers wrote: Hi Alex, I have a php file I made just a few months ago. It takes a gif, jpeg or png of any size and sizes it proportionately to a specified size and then outputs a png. If the image is a transparent png or transparent gif, it will still hold the transparency. This is just a test page and it tested ok for me, but it is my first one. I also tested it on PHP 5. Dont know about compatibility to older versions. Knowing that, here you go. http://designdrumm.com/upload_images_test.php.zip HTH, Karl Bad link. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD - import a PNG image and make transparant
On Thu, 2010-05-13 at 00:12 +0100, Alex Davies wrote: > Hi, > > I am trying to import a PNG image from disk, place it on top of a > transparant image created in GD and output it to the browser. In the case of > a low opacity setting, I would expect to see the background colour from the > HTML page. > > If I set the opacity to 0, everything works - I end up with a transparant > image. > > However, if I set it for any value >0 (even 1) instead of a > very-faint-image the whole thing goes black. As the opacity level goes up > from 0, the amount of black reduces and the amount of imported image > increases - but this is not what I want. > > I am using this code: > > $src = imagecreatefrompng('test.png'); > $img_width = imagesx($src); > $img_height = imagesy($src); > > // Create trans image > $dest = imagecreatetruecolor($img_width, $img_height); > //imagesavealpha($dest, true); // This has no effect it appears > $trans_colour = imagecolorallocatealpha($dest, 0, 255, 0, 128); > > // Make the background transparent > imagecolortransparent($dest, $trans_colour); > //imagefill($dest, 0, 0, $trans_colour); // This does not work > > // Merge src on top of dest, with opacity of 1 in this case > imagecopymerge($dest, $src, 0, 0, 0, 0, $img_width, $img_height, 1); > > // Output and free from memory > header('Content-Type: image/png'); > imagepng($dest); > ?> > > The images that this outputs, at opacity levels 0,1 and 80 on a red and > green background (screenshots of a HTML page) can be downloaded from > http://www.box.net/shared/h9zn4tjgro > > Any help appreciated! > > Cheers, > > Alex How exactly are you setting the opacity for the image? The traditional way is to use imagecolorallocatealpha() on the source. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] GD - import a PNG image and make transparant
Hi Alex, I have a php file I made just a few months ago. It takes a gif, jpeg or png of any size and sizes it proportionately to a specified size and then outputs a png. If the image is a transparent png or transparent gif, it will still hold the transparency. This is just a test page and it tested ok for me, but it is my first one. I also tested it on PHP 5. Dont know about compatibility to older versions. Knowing that, here you go. http://designdrumm.com/upload_images_test.php.zip HTH, Karl On May 12, 2010, at 6:12 PM, Alex Davies wrote: Hi, I am trying to import a PNG image from disk, place it on top of a transparant image created in GD and output it to the browser. In the case of a low opacity setting, I would expect to see the background colour from the HTML page. If I set the opacity to 0, everything works - I end up with a transparant image. However, if I set it for any value >0 (even 1) instead of a very-faint-image the whole thing goes black. As the opacity level goes up from 0, the amount of black reduces and the amount of imported image increases - but this is not what I want. I am using this code: The images that this outputs, at opacity levels 0,1 and 80 on a red and green background (screenshots of a HTML page) can be downloaded from http://www.box.net/shared/h9zn4tjgro Any help appreciated! Cheers, Alex Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD - import a PNG image and make transparant
Hi, I am trying to import a PNG image from disk, place it on top of a transparant image created in GD and output it to the browser. In the case of a low opacity setting, I would expect to see the background colour from the HTML page. If I set the opacity to 0, everything works - I end up with a transparant image. However, if I set it for any value >0 (even 1) instead of a very-faint-image the whole thing goes black. As the opacity level goes up from 0, the amount of black reduces and the amount of imported image increases - but this is not what I want. I am using this code: The images that this outputs, at opacity levels 0,1 and 80 on a red and green background (screenshots of a HTML page) can be downloaded from http://www.box.net/shared/h9zn4tjgro Any help appreciated! Cheers, Alex
Re: [PHP] PHP GD - Create a "flag"
On Sun, 2010-05-09 at 14:21 +0200, Giorgio wrote: > Thankyou Ashley, > > as I only need 5 colors for each image, my idea was to create a single pixel > image for each color and save it on the hd (so that i don't have to create > it every time). > > I've finally used this code: > > imagecopymerge($base, $img1, 0, 0, 1, 1, 100, 500, 75); > imagecopymerge($base, $img2, 100, 0, 1, 1, 100, 500, 75); > imagecopymerge($base, $img3, 200, 0, 1, 1, 100, 500, 75); > imagecopymerge($base, $img4, 300, 0, 1, 1, 100, 500, 75); > imagecopymerge($base, $img5, 400, 0, 1, 1, 100, 500, 75); > > ($imgX are 1*1 images. I have a function that checks if they exists) > > You can see the output here: http://aagmns47.facebook.joyent.us/sdna/. > > I think that copying a 1*1 image (and as said i'll cache all 1*1 colors on > the hd) on a background is less resource-expensive than creating a coloured > rectangle every time, isn't it? > > Giorgio > > > 2010/5/9 Ashley Sheridan > > > On Sat, 2010-05-08 at 18:48 +0200, Giorgio wrote: > > > > Hi, > > > > i've just started using GD libraries. My purpose is to create something like > > a flag. > > > > So that i have a 600*600 px background image, and a 1*1 px image for each > > colour I need. > > > > Ok now let's say i want to colour a third of the background image. I can use > > this code: > > > > imagecopymerge($base, $img1, 0, 0, 0, 0, 200, 600, 85); > > > > It will simply make red first 200 px (on x axys) of the bg image. And this > > work. > > > > Now the problem is: how can i add another colour on pixels from 201 (201 > > right? not 200?) to 400? > > > > Thankyou > > > > > > > > Erm, why don't you use something like imagerectangle() ? It's far easier > > and less resource intensive than having loads of single-pixel images for > > each colour you want to use. > > > > Thanks, > > Ash > > http://www.ashleysheridan.co.uk > > > > > > > > Sorry, use imagefilledrectangle() instead of imagerectangle() in the example I just gave you! Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] PHP GD - Create a "flag"
On Sun, 2010-05-09 at 14:21 +0200, Giorgio wrote: > Thankyou Ashley, > > as I only need 5 colors for each image, my idea was to create a single pixel > image for each color and save it on the hd (so that i don't have to create > it every time). > > I've finally used this code: > > imagecopymerge($base, $img1, 0, 0, 1, 1, 100, 500, 75); > imagecopymerge($base, $img2, 100, 0, 1, 1, 100, 500, 75); > imagecopymerge($base, $img3, 200, 0, 1, 1, 100, 500, 75); > imagecopymerge($base, $img4, 300, 0, 1, 1, 100, 500, 75); > imagecopymerge($base, $img5, 400, 0, 1, 1, 100, 500, 75); > > ($imgX are 1*1 images. I have a function that checks if they exists) > > You can see the output here: http://aagmns47.facebook.joyent.us/sdna/. > > I think that copying a 1*1 image (and as said i'll cache all 1*1 colors on > the hd) on a background is less resource-expensive than creating a coloured > rectangle every time, isn't it? > > Giorgio > > > 2010/5/9 Ashley Sheridan > > > On Sat, 2010-05-08 at 18:48 +0200, Giorgio wrote: > > > > Hi, > > > > i've just started using GD libraries. My purpose is to create something like > > a flag. > > > > So that i have a 600*600 px background image, and a 1*1 px image for each > > colour I need. > > > > Ok now let's say i want to colour a third of the background image. I can use > > this code: > > > > imagecopymerge($base, $img1, 0, 0, 0, 0, 200, 600, 85); > > > > It will simply make red first 200 px (on x axys) of the bg image. And this > > work. > > > > Now the problem is: how can i add another colour on pixels from 201 (201 > > right? not 200?) to 400? > > > > Thankyou > > > > > > > > Erm, why don't you use something like imagerectangle() ? It's far easier > > and less resource intensive than having loads of single-pixel images for > > each colour you want to use. > > > > Thanks, > > Ash > > http://www.ashleysheridan.co.uk > > > > > > > > No, you use imagerectangle() directly on the final image, no need to use imagecopymerge() at all! $colour1 = imagecolorallocate($base, 255, 105, 180); $colour2 = imagecolorallocate($base, 255, 255, 255); $colour3 = imagecolorallocate($base, 132, 135, 28); $colour4 = imagecolorallocate($base, 88, 105, 180); $colour5 = imagecolorallocate($base, 0, 0, 0); imagerectangle($base, 0, 0, 100, 500, $colour1); imagerectangle($base, 100, 0, 200, 500, $colour2); imagerectangle($base, 200, 0, 300, 500, $colour3); imagerectangle($base, 300, 0, 400, 500, $colour4); imagerectangle($base, 400, 0, 500, 500, $colour5); It looks like more code, but you'll really appreciate it if you get a lot of visitors who are triggering these images to be created dynamically. Copying a single-pixel image and resizing it into a much larger area is always going to be more costly than using the native imagerectangle() function. Also, the above way allows you to create the colours dynamically for the image from within your script, and not have to create a new 1x1 pixel image each time! Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] PHP GD - Create a "flag"
Thankyou Ashley, as I only need 5 colors for each image, my idea was to create a single pixel image for each color and save it on the hd (so that i don't have to create it every time). I've finally used this code: imagecopymerge($base, $img1, 0, 0, 1, 1, 100, 500, 75); imagecopymerge($base, $img2, 100, 0, 1, 1, 100, 500, 75); imagecopymerge($base, $img3, 200, 0, 1, 1, 100, 500, 75); imagecopymerge($base, $img4, 300, 0, 1, 1, 100, 500, 75); imagecopymerge($base, $img5, 400, 0, 1, 1, 100, 500, 75); ($imgX are 1*1 images. I have a function that checks if they exists) You can see the output here: http://aagmns47.facebook.joyent.us/sdna/. I think that copying a 1*1 image (and as said i'll cache all 1*1 colors on the hd) on a background is less resource-expensive than creating a coloured rectangle every time, isn't it? Giorgio 2010/5/9 Ashley Sheridan > On Sat, 2010-05-08 at 18:48 +0200, Giorgio wrote: > > Hi, > > i've just started using GD libraries. My purpose is to create something like > a flag. > > So that i have a 600*600 px background image, and a 1*1 px image for each > colour I need. > > Ok now let's say i want to colour a third of the background image. I can use > this code: > > imagecopymerge($base, $img1, 0, 0, 0, 0, 200, 600, 85); > > It will simply make red first 200 px (on x axys) of the bg image. And this > work. > > Now the problem is: how can i add another colour on pixels from 201 (201 > right? not 200?) to 400? > > Thankyou > > > > Erm, why don't you use something like imagerectangle() ? It's far easier > and less resource intensive than having loads of single-pixel images for > each colour you want to use. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > -- -- AnotherNetFellow Email: anothernetfel...@gmail.com
Re: [PHP] PHP GD - Create a "flag"
On Sat, 2010-05-08 at 18:48 +0200, Giorgio wrote: > Hi, > > i've just started using GD libraries. My purpose is to create something like > a flag. > > So that i have a 600*600 px background image, and a 1*1 px image for each > colour I need. > > Ok now let's say i want to colour a third of the background image. I can use > this code: > > imagecopymerge($base, $img1, 0, 0, 0, 0, 200, 600, 85); > > It will simply make red first 200 px (on x axys) of the bg image. And this > work. > > Now the problem is: how can i add another colour on pixels from 201 (201 > right? not 200?) to 400? > > Thankyou > Erm, why don't you use something like imagerectangle() ? It's far easier and less resource intensive than having loads of single-pixel images for each colour you want to use. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] PHP GD - Create a "flag"
Hi, i've just started using GD libraries. My purpose is to create something like a flag. So that i have a 600*600 px background image, and a 1*1 px image for each colour I need. Ok now let's say i want to colour a third of the background image. I can use this code: imagecopymerge($base, $img1, 0, 0, 0, 0, 200, 600, 85); It will simply make red first 200 px (on x axys) of the bg image. And this work. Now the problem is: how can i add another colour on pixels from 201 (201 right? not 200?) to 400? Thankyou -- -- AnotherNetFellow Email: anothernetfel...@gmail.com
Re: [PHP] [GD] Image errors
Martin Scotta wrote: > Why are you ussing GD? > All you need is output the image to the browser? > > try this... I didn't test/run this code, but it may work... > > public function showPicture( $id ) { > header('Content-type:' . mime_content_type( $this->updir . $id . > '.png' ) ); > readfile( $this->updir . $id . '.png' ); > } > > hey, look, just 2 lines! > But it doesn't convert the image from whatever came in to a JPEG output, which is what the OP's code appears to be trying to do (and possibly ought to work...) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [GD] Image errors
Ash, Martin, Seems you are both wandering around the obvious problem... I suspect that $tipo (in the next line) is *supposed* to be $type - sounds like a partial Italian translation to me... So given that $type="imagecreatefrompng" (for example, if the mime check returns 'png' - not very reliable, I suspect), then $immagine = $type($this->updir.$id.'.png') should create a GD resource from the file, but the image appears to be empty. My take on this is: OP says he gets the same result from $immagine = imagecreatefromjpeg(this->updir.$id.'.png') - well I might expect to get an error message if I loaded a PNG expecting it to be a JPEG, but I certainly wouldn't expect an image. On some basic tests, I find that mime_content_type() is not defined on my system, so ignoring that and trying to load a PNG file using imagecreatefromjpeg results in pretty much the same result as the OP... Conclusions: First: if you use Italian for your variable names, don't change half of their instances to English... Second: Make sure you actually know the mime type of a file before you try to load it into GD... My version of this would test against known image types to try the GD function: foreach (Array('png','jpeg','gif') as $typeName) { $type = 'imagecreatefrom'.$typeName; $immagine = $type(this->updir.$id.'.png'le); if (is_resource($immagine)) { header('Content-type: image/jpeg'); imagejpeg($immagine,null,100); imagedestroy($immagine); break; } } header('HTTP/1.0 500 File is not an allowed image type'); -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [GD] Image errors
Why are you ussing GD? All you need is output the image to the browser? try this... I didn't test/run this code, but it may work... public function showPicture( $id ) { header('Content-type:' . mime_content_type( $this->updir . $id . '.png' ) ); readfile( $this->updir . $id . '.png' ); } hey, look, just 2 lines! On Tue, Jul 14, 2009 at 2:20 PM, Ashley Sheridan wrote: > On Tue, 2009-07-14 at 14:16 -0300, Martin Scotta wrote: >> On Tue, Jul 14, 2009 at 1:48 PM, Ashley >> Sheridan wrote: >> > On Tue, 2009-07-14 at 13:41 -0300, Martin Scotta wrote: >> >> He is calling the function by variable >> >> >> >> something like this >> >> >> >> $func = 'var_dump'; >> >> >> >> $func( new Foo ); >> >> >> >> On Tue, Jul 14, 2009 at 1:30 PM, Ashley >> >> Sheridan wrote: >> >> > On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote: >> >> >> $immagine = $tipo($this->updir.$id.'.png'); >> >> >> >> >> >> $tipo is undefined >> >> >> >> >> >> >> >> >> On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino >> >> >> volante wrote: >> >> >> > Hi to all >> >> >> > >> >> >> > I get a problem processing an image with GD libraries. >> >> >> > >> >> >> > This is my function >> >> >> > >> >> >> > public function showPicture($id) { >> >> >> > header('Content-type: image/jpeg'); >> >> >> > $mime = mime_content_type($this->updir.$id.'.png'); >> >> >> > $type = explode('/',$mime); >> >> >> > $type = 'imagecreatefrom'.$type[1]; >> >> >> > $immagine = $tipo($this->updir.$id.'.png'); >> >> >> > imagejpeg($immagine,null,100); >> >> >> > imagedestroy($immagine); >> >> >> > } >> >> >> > >> >> >> > If i commentize the "header" function i get a lot of strange simbols >> >> >> > (such >> >> >> > as the code of a jpeg image!) but no errors. >> >> >> > The result of this code is a blank page. In Firefox the title sets to >> >> >> > "picture.php (JPEG image)" and if i right-click it and click on >> >> >> > "Proprieties" i get "0px × 0px (resized as 315px × 19px)". >> >> >> > >> >> >> > P.S.: I get the same result when I write $immagine = >> >> >> > imagecreatefromjpeg(...) >> >> >> > >> >> >> > (Sorry for my english) >> >> >> > >> >> >> > Thanks in advance, >> >> >> > Alfio. >> >> >> > >> >> >> > -- >> >> >> > PHP General Mailing List (http://www.php.net/) >> >> >> > To unsubscribe, visit: http://www.php.net/unsub.php >> >> >> > >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> Martin Scotta >> >> >> >> >> > Also, it doesn't look like you're actually doing anything with $type >> >> > >> >> > Thanks >> >> > Ash >> >> > www.ashleysheridan.co.uk >> >> > >> >> > >> >> >> >> >> >> >> >> -- >> >> Martin Scotta >> >> >> > >> > Bottom post ;) >> > >> > $type = explode('/',$mime); >> > $type = 'imagecreatefrom'.$type[1]; >> > >> > $immagine = $tipo($this->updir.$id.'.png'); >> > imagejpeg($immagine,null,100); >> > imagedestroy($immagine); >> > >> > I'm not sure you understood what I meant. line 2 above $type is assigned >> > to the string 'imagecreatefrom'.$type[1]; >> > >> > Now I assume that was to be used later in some sort of eval() statement, >> > but its never called again, so the line really does nothing. >> > >> > Thanks >> > Ash >> > www.ashleysheridan.co.uk >> > >> > >> >> Mmmm, No >> >> $type = explode('/',$mime); # type is array >> $type = 'imagecreatefrom'.$type[1]; # type is a string >> >> He is actually re-assigning the var ussing the content of the var. >> Sounds crazy, but I use this method a lot, it helps to keep the scope clean. >> > > It's not crazy, I do it a lot, but he *does nothing with it* after that, > and the scope of the variable is limited to the function. > > Thanks > Ash > www.ashleysheridan.co.uk > > -- Martin Scotta -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [GD] Image errors
On Tue, 2009-07-14 at 14:16 -0300, Martin Scotta wrote: > On Tue, Jul 14, 2009 at 1:48 PM, Ashley > Sheridan wrote: > > On Tue, 2009-07-14 at 13:41 -0300, Martin Scotta wrote: > >> He is calling the function by variable > >> > >> something like this > >> > >> $func = 'var_dump'; > >> > >> $func( new Foo ); > >> > >> On Tue, Jul 14, 2009 at 1:30 PM, Ashley > >> Sheridan wrote: > >> > On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote: > >> >> $immagine = $tipo($this->updir.$id.'.png'); > >> >> > >> >> $tipo is undefined > >> >> > >> >> > >> >> On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino > >> >> volante wrote: > >> >> > Hi to all > >> >> > > >> >> > I get a problem processing an image with GD libraries. > >> >> > > >> >> > This is my function > >> >> > > >> >> > public function showPicture($id) { > >> >> > header('Content-type: image/jpeg'); > >> >> > $mime = mime_content_type($this->updir.$id.'.png'); > >> >> > $type = explode('/',$mime); > >> >> > $type = 'imagecreatefrom'.$type[1]; > >> >> > $immagine = $tipo($this->updir.$id.'.png'); > >> >> > imagejpeg($immagine,null,100); > >> >> > imagedestroy($immagine); > >> >> > } > >> >> > > >> >> > If i commentize the "header" function i get a lot of strange simbols > >> >> > (such > >> >> > as the code of a jpeg image!) but no errors. > >> >> > The result of this code is a blank page. In Firefox the title sets to > >> >> > "picture.php (JPEG image)" and if i right-click it and click on > >> >> > "Proprieties" i get "0px × 0px (resized as 315px × 19px)". > >> >> > > >> >> > P.S.: I get the same result when I write $immagine = > >> >> > imagecreatefromjpeg(...) > >> >> > > >> >> > (Sorry for my english) > >> >> > > >> >> > Thanks in advance, > >> >> > Alfio. > >> >> > > >> >> > -- > >> >> > PHP General Mailing List (http://www.php.net/) > >> >> > To unsubscribe, visit: http://www.php.net/unsub.php > >> >> > > >> >> > > >> >> > >> >> > >> >> > >> >> -- > >> >> Martin Scotta > >> >> > >> > Also, it doesn't look like you're actually doing anything with $type > >> > > >> > Thanks > >> > Ash > >> > www.ashleysheridan.co.uk > >> > > >> > > >> > >> > >> > >> -- > >> Martin Scotta > >> > > > > Bottom post ;) > > > > $type = explode('/',$mime); > > $type = 'imagecreatefrom'.$type[1]; > > > > $immagine = $tipo($this->updir.$id.'.png'); > > imagejpeg($immagine,null,100); > > imagedestroy($immagine); > > > > I'm not sure you understood what I meant. line 2 above $type is assigned > > to the string 'imagecreatefrom'.$type[1]; > > > > Now I assume that was to be used later in some sort of eval() statement, > > but its never called again, so the line really does nothing. > > > > Thanks > > Ash > > www.ashleysheridan.co.uk > > > > > > Mmmm, No > > $type = explode('/',$mime); # type is array > $type = 'imagecreatefrom'.$type[1]; # type is a string > > He is actually re-assigning the var ussing the content of the var. > Sounds crazy, but I use this method a lot, it helps to keep the scope clean. > It's not crazy, I do it a lot, but he *does nothing with it* after that, and the scope of the variable is limited to the function. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [GD] Image errors
On Tue, Jul 14, 2009 at 1:48 PM, Ashley Sheridan wrote: > On Tue, 2009-07-14 at 13:41 -0300, Martin Scotta wrote: >> He is calling the function by variable >> >> something like this >> >> $func = 'var_dump'; >> >> $func( new Foo ); >> >> On Tue, Jul 14, 2009 at 1:30 PM, Ashley >> Sheridan wrote: >> > On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote: >> >> $immagine = $tipo($this->updir.$id.'.png'); >> >> >> >> $tipo is undefined >> >> >> >> >> >> On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino >> >> volante wrote: >> >> > Hi to all >> >> > >> >> > I get a problem processing an image with GD libraries. >> >> > >> >> > This is my function >> >> > >> >> > public function showPicture($id) { >> >> > header('Content-type: image/jpeg'); >> >> > $mime = mime_content_type($this->updir.$id.'.png'); >> >> > $type = explode('/',$mime); >> >> > $type = 'imagecreatefrom'.$type[1]; >> >> > $immagine = $tipo($this->updir.$id.'.png'); >> >> > imagejpeg($immagine,null,100); >> >> > imagedestroy($immagine); >> >> > } >> >> > >> >> > If i commentize the "header" function i get a lot of strange simbols >> >> > (such >> >> > as the code of a jpeg image!) but no errors. >> >> > The result of this code is a blank page. In Firefox the title sets to >> >> > "picture.php (JPEG image)" and if i right-click it and click on >> >> > "Proprieties" i get "0px × 0px (resized as 315px × 19px)". >> >> > >> >> > P.S.: I get the same result when I write $immagine = >> >> > imagecreatefromjpeg(...) >> >> > >> >> > (Sorry for my english) >> >> > >> >> > Thanks in advance, >> >> > Alfio. >> >> > >> >> > -- >> >> > PHP General Mailing List (http://www.php.net/) >> >> > To unsubscribe, visit: http://www.php.net/unsub.php >> >> > >> >> > >> >> >> >> >> >> >> >> -- >> >> Martin Scotta >> >> >> > Also, it doesn't look like you're actually doing anything with $type >> > >> > Thanks >> > Ash >> > www.ashleysheridan.co.uk >> > >> > >> >> >> >> -- >> Martin Scotta >> > > Bottom post ;) > > $type = explode('/',$mime); > $type = 'imagecreatefrom'.$type[1]; > > $immagine = $tipo($this->updir.$id.'.png'); > imagejpeg($immagine,null,100); > imagedestroy($immagine); > > I'm not sure you understood what I meant. line 2 above $type is assigned > to the string 'imagecreatefrom'.$type[1]; > > Now I assume that was to be used later in some sort of eval() statement, > but its never called again, so the line really does nothing. > > Thanks > Ash > www.ashleysheridan.co.uk > > Mmmm, No $type = explode('/',$mime); # type is array $type = 'imagecreatefrom'.$type[1]; # type is a string He is actually re-assigning the var ussing the content of the var. Sounds crazy, but I use this method a lot, it helps to keep the scope clean. -- Martin Scotta ps. "tipo" is "type" in Spanish -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [GD] Image errors
On Tue, 2009-07-14 at 13:41 -0300, Martin Scotta wrote: > He is calling the function by variable > > something like this > > $func = 'var_dump'; > > $func( new Foo ); > > On Tue, Jul 14, 2009 at 1:30 PM, Ashley > Sheridan wrote: > > On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote: > >> $immagine = $tipo($this->updir.$id.'.png'); > >> > >> $tipo is undefined > >> > >> > >> On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino > >> volante wrote: > >> > Hi to all > >> > > >> > I get a problem processing an image with GD libraries. > >> > > >> > This is my function > >> > > >> > public function showPicture($id) { > >> > header('Content-type: image/jpeg'); > >> > $mime = mime_content_type($this->updir.$id.'.png'); > >> > $type = explode('/',$mime); > >> > $type = 'imagecreatefrom'.$type[1]; > >> > $immagine = $tipo($this->updir.$id.'.png'); > >> > imagejpeg($immagine,null,100); > >> > imagedestroy($immagine); > >> > } > >> > > >> > If i commentize the "header" function i get a lot of strange simbols > >> > (such > >> > as the code of a jpeg image!) but no errors. > >> > The result of this code is a blank page. In Firefox the title sets to > >> > "picture.php (JPEG image)" and if i right-click it and click on > >> > "Proprieties" i get "0px × 0px (resized as 315px × 19px)". > >> > > >> > P.S.: I get the same result when I write $immagine = > >> > imagecreatefromjpeg(...) > >> > > >> > (Sorry for my english) > >> > > >> > Thanks in advance, > >> > Alfio. > >> > > >> > -- > >> > PHP General Mailing List (http://www.php.net/) > >> > To unsubscribe, visit: http://www.php.net/unsub.php > >> > > >> > > >> > >> > >> > >> -- > >> Martin Scotta > >> > > Also, it doesn't look like you're actually doing anything with $type > > > > Thanks > > Ash > > www.ashleysheridan.co.uk > > > > > > > > -- > Martin Scotta > Bottom post ;) $type = explode('/',$mime); $type = 'imagecreatefrom'.$type[1]; $immagine = $tipo($this->updir.$id.'.png'); imagejpeg($immagine,null,100); imagedestroy($immagine); I'm not sure you understood what I meant. line 2 above $type is assigned to the string 'imagecreatefrom'.$type[1]; Now I assume that was to be used later in some sort of eval() statement, but its never called again, so the line really does nothing. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [GD] Image errors
He is calling the function by variable something like this $func = 'var_dump'; $func( new Foo ); On Tue, Jul 14, 2009 at 1:30 PM, Ashley Sheridan wrote: > On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote: >> $immagine = $tipo($this->updir.$id.'.png'); >> >> $tipo is undefined >> >> >> On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino >> volante wrote: >> > Hi to all >> > >> > I get a problem processing an image with GD libraries. >> > >> > This is my function >> > >> > public function showPicture($id) { >> > header('Content-type: image/jpeg'); >> > $mime = mime_content_type($this->updir.$id.'.png'); >> > $type = explode('/',$mime); >> > $type = 'imagecreatefrom'.$type[1]; >> > $immagine = $tipo($this->updir.$id.'.png'); >> > imagejpeg($immagine,null,100); >> > imagedestroy($immagine); >> > } >> > >> > If i commentize the "header" function i get a lot of strange simbols (such >> > as the code of a jpeg image!) but no errors. >> > The result of this code is a blank page. In Firefox the title sets to >> > "picture.php (JPEG image)" and if i right-click it and click on >> > "Proprieties" i get "0px × 0px (resized as 315px × 19px)". >> > >> > P.S.: I get the same result when I write $immagine = >> > imagecreatefromjpeg(...) >> > >> > (Sorry for my english) >> > >> > Thanks in advance, >> > Alfio. >> > >> > -- >> > PHP General Mailing List (http://www.php.net/) >> > To unsubscribe, visit: http://www.php.net/unsub.php >> > >> > >> >> >> >> -- >> Martin Scotta >> > Also, it doesn't look like you're actually doing anything with $type > > Thanks > Ash > www.ashleysheridan.co.uk > > -- Martin Scotta -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [GD] Image errors
On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote: > $immagine = $tipo($this->updir.$id.'.png'); > > $tipo is undefined > > > On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino > volante wrote: > > Hi to all > > > > I get a problem processing an image with GD libraries. > > > > This is my function > > > > public function showPicture($id) { > > header('Content-type: image/jpeg'); > > $mime = mime_content_type($this->updir.$id.'.png'); > > $type = explode('/',$mime); > > $type = 'imagecreatefrom'.$type[1]; > > $immagine = $tipo($this->updir.$id.'.png'); > > imagejpeg($immagine,null,100); > > imagedestroy($immagine); > > } > > > > If i commentize the "header" function i get a lot of strange simbols (such > > as the code of a jpeg image!) but no errors. > > The result of this code is a blank page. In Firefox the title sets to > > "picture.php (JPEG image)" and if i right-click it and click on > > "Proprieties" i get "0px × 0px (resized as 315px × 19px)". > > > > P.S.: I get the same result when I write $immagine = > > imagecreatefromjpeg(...) > > > > (Sorry for my english) > > > > Thanks in advance, > > Alfio. > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- > Martin Scotta > Also, it doesn't look like you're actually doing anything with $type Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [GD] Image errors
$immagine = $tipo($this->updir.$id.'.png'); $tipo is undefined On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino volante wrote: > Hi to all > > I get a problem processing an image with GD libraries. > > This is my function > > public function showPicture($id) { > header('Content-type: image/jpeg'); > $mime = mime_content_type($this->updir.$id.'.png'); > $type = explode('/',$mime); > $type = 'imagecreatefrom'.$type[1]; > $immagine = $tipo($this->updir.$id.'.png'); > imagejpeg($immagine,null,100); > imagedestroy($immagine); > } > > If i commentize the "header" function i get a lot of strange simbols (such > as the code of a jpeg image!) but no errors. > The result of this code is a blank page. In Firefox the title sets to > "picture.php (JPEG image)" and if i right-click it and click on > "Proprieties" i get "0px × 0px (resized as 315px × 19px)". > > P.S.: I get the same result when I write $immagine = > imagecreatefromjpeg(...) > > (Sorry for my english) > > Thanks in advance, > Alfio. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Martin Scotta -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [GD] Image errors
Hi to all I get a problem processing an image with GD libraries. This is my function public function showPicture($id) { header('Content-type: image/jpeg'); $mime = mime_content_type($this->updir.$id.'.png'); $type = explode('/',$mime); $type = 'imagecreatefrom'.$type[1]; $immagine = $tipo($this->updir.$id.'.png'); imagejpeg($immagine,null,100); imagedestroy($immagine); } If i commentize the "header" function i get a lot of strange simbols (such as the code of a jpeg image!) but no errors. The result of this code is a blank page. In Firefox the title sets to "picture.php (JPEG image)" and if i right-click it and click on "Proprieties" i get "0px × 0px (resized as 315px × 19px)". P.S.: I get the same result when I write $immagine = imagecreatefromjpeg(...) (Sorry for my english) Thanks in advance, Alfio. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD to IMAGEMAGICK
Hello. I have this code and the getFrame returns a GD truecolor image. However, I want to convert to imagemagick after I get that frame from ffmpeg. Here's my code: // GRAB A FRAME FROM THE VIDEO FOR A THUMB VIEW $video = new ffmpeg_movie($data_temp, false); $frame = $video->getFrame(90); //returns a ffmpeg_frame() object $frame_full = $frame->toGDImage(); // Returns a truecolor GD image of the frame. // Here is where it fails so I'm assuming I need to convert the $frame_full into something Imagick friendly. Any ideas? Or am I not returning any data to the frame_full to process? $frame_full = new Imagick($frame_full); // get dimensions $frame_height = $frame_full->getImageHeight(); $frame_width = $frame_full->getImageWidth(); ERROR: Fatal error: Uncaught exception 'ImagickException' with message 'Can not process empty Imagick object' in /home/httpd/html/domain.com/public_html/upload/albums.php:214 Stack trace: #0 /home/httpd/html/domain.com/public_html/upload/albums.php(214): Imagick->getimageheight() #1 /home/httpd/html/domain.com/public_html/upload/albums.php(26): upload_content(Object(ADODB_mysql), '58669', '77', 'my videos', 'video') #2 {main} thrown in /home/httpd/html/domain.com/public_html/upload/albums.php on line 214 Thanks for any help, T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD and Converting a Transparent PNG-8 to a Transparent GIF
I got it to work :) Like you had recommended, I found a script in http://php.net/imagecolortransparent from: fmkaiba at optonline dot net 07-Feb-2008 08:05. The function is called, createthumb Cheers Graham On Jan 18, 2009, at 4:46 PM, Jochem Maas wrote: Graham Anderson schreef: Hi I am having problems getting GD to convert a transparent PNG-8 to a transparent GIF The below WILL produce a GIF...but leaves a white background # Convert the PreExisting PNG Image to a GIF $img = imagecreatefrompng($pngPath); # Set the GIF to be transparent: Does not seem to work $trans_color = imagecolortransparent($img ); $trans_index = imagecolorallocate($img, $trans_color['red'], $trans_color['green'], $trans_color['blue'] ); imagecolortransparent($img, $trans_index ); I can't see the above code doing much useful. the problem is somewhat more involved, png uses an alpha channel to determine how much transparency a given pixel has, with gif a pixel is either transparent or not, essentially a given colour in the gif's palette is marked as transparent and all pixels with that color are therefore shown as transparent. try the code here (no idea how well it works): http://demo.pixelsandpages.com/php-tests/images/test.html and/or dig into the user comments here: http://php.net/imagecolortransparent # Save the Image as a GIF in the directory imagegif($img, $gifAbsolutePath); Is there another way that works? Many thanks in advance G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD and Converting a Transparent PNG-8 to a Transparent GIF
Thanks for the reply I tried the example (below) from the link and still get a gif with white background. Maybe, you can only do this with PNG-24s...not PNG-8s? Anyone else know if this can work? # Convert the PreExisting PNG Image to a GIF $img = imagecreatefrompng($pngPath); $gifAbsolutePath = PROJECT_ROOT_DIR.'/'.$gifDir.'/'.$gif; $transparentColor = imagecolorallocate($img, 0xfe, 0x3, 0xf4 ); //$ditherHistory = array(); //stores number of times it was transparent $height = imagesy($img); $width = imagesx($img); for($x = 0; $x < $width; $x++): for($y = 0; $y < $height; $y++): $alpha = (imagecolorat($img,$x,$y) & 0x7F00) >> 24;//127 is completely TRANSPARENT, 0 opaque //DITHER! if($alpha>3&&( $alpha >=127-3 || (rand(0,127))>=(127-$alpha) )){ imagesetpixel($img,$x,$y,$transparentColor); } endfor; endfor; imagecolortransparent($img, $transparentColor); # Save the Image as a GIF in the directory $gifDir imagegif($img, $gifAbsolutePath); imagedestroy($img); On Jan 18, 2009, at 4:46 PM, Jochem Maas wrote: Graham Anderson schreef: Hi I am having problems getting GD to convert a transparent PNG-8 to a transparent GIF The below WILL produce a GIF...but leaves a white background # Convert the PreExisting PNG Image to a GIF $img = imagecreatefrompng($pngPath); # Set the GIF to be transparent: Does not seem to work $trans_color = imagecolortransparent($img ); $trans_index = imagecolorallocate($img, $trans_color['red'], $trans_color['green'], $trans_color['blue'] ); imagecolortransparent($img, $trans_index ); I can't see the above code doing much useful. the problem is somewhat more involved, png uses an alpha channel to determine how much transparency a given pixel has, with gif a pixel is either transparent or not, essentially a given colour in the gif's palette is marked as transparent and all pixels with that color are therefore shown as transparent. try the code here (no idea how well it works): http://demo.pixelsandpages.com/php-tests/images/test.html and/or dig into the user comments here: http://php.net/imagecolortransparent # Save the Image as a GIF in the directory imagegif($img, $gifAbsolutePath); Is there another way that works? Many thanks in advance G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD and Converting a Transparent PNG-8 to a Transparent GIF
Graham Anderson schreef: > Hi > > I am having problems getting GD to convert a transparent PNG-8 to a > transparent GIF > The below WILL produce a GIF...but leaves a white background > > # Convert the PreExisting PNG Image to a GIF > $img = imagecreatefrompng($pngPath); > > # Set the GIF to be transparent: Does not seem to work > $trans_color = imagecolortransparent($img ); > $trans_index = imagecolorallocate($img, $trans_color['red'], > $trans_color['green'], $trans_color['blue'] ); > imagecolortransparent($img, $trans_index ); I can't see the above code doing much useful. the problem is somewhat more involved, png uses an alpha channel to determine how much transparency a given pixel has, with gif a pixel is either transparent or not, essentially a given colour in the gif's palette is marked as transparent and all pixels with that color are therefore shown as transparent. try the code here (no idea how well it works): http://demo.pixelsandpages.com/php-tests/images/test.html and/or dig into the user comments here: http://php.net/imagecolortransparent > > # Save the Image as a GIF in the directory > imagegif($img, $gifAbsolutePath); > > > Is there another way that works? > > Many thanks in advance > > G > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD and Converting a Transparent PNG-8 to a Transparent GIF
Hi I am having problems getting GD to convert a transparent PNG-8 to a transparent GIF The below WILL produce a GIF...but leaves a white background # Convert the PreExisting PNG Image to a GIF $img = imagecreatefrompng($pngPath); # Set the GIF to be transparent: Does not seem to work $trans_color = imagecolortransparent($img ); $trans_index = imagecolorallocate($img, $trans_color['red'], $trans_color['green'], $trans_color['blue'] ); imagecolortransparent($img, $trans_index ); # Save the Image as a GIF in the directory imagegif($img, $gifAbsolutePath); Is there another way that works? Many thanks in advance G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-gd problems on Ubuntu 8.04
I did, but it doens't help On Thursday 14 August 2008 18:58:57 Micah Gersten wrote: > Make sure that your php.ini file for the cli is loading gd. > > Thank you, > Micah Gersten > onShore Networks > Internal Developer > http://www.onshore.com > > Chantal Rosmuller wrote: > > Hi list, > > > > I have a PHP problem on Ubuntu 8.04, the php-gd package for ubuntu > > doesn't use the gd bundles library for security reasons if I understood > > this correctly. I solved it by downloading a php-gd fedora rpm and > > converting it to .deb with alien. it works for the apache websites but > > not for the commandline. I get the follwoing error: > > > > > > php /path/to/process.php variable1 variable2 > > > > Warning: Wrong parameter count for strpos() in /path/to/config.php on > > line 30 > > JpGraph Error This PHP installation is not configured with the GD > > library. Please recompile PHP with GD support to run JpGraph. (Neither > > function imagetypes() nor imagecreatefromstring() does exist)ro > > > > does anyone know how to fix this? > > > > regards Chantal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-gd problems on Ubuntu 8.04
Which gd package did you install? Php5-gd worked for me. Could be something like it trying to install a php4 module onto php5 Luke Slater Lead Developer NuVoo On 18 Aug 2008, at 15:47, Chantal Rosmuller <[EMAIL PROTECTED]> wrote: I did, but it doens't help On Thursday 14 August 2008 18:58:57 Micah Gersten wrote: Make sure that your php.ini file for the cli is loading gd. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Chantal Rosmuller wrote: Hi list, I have a PHP problem on Ubuntu 8.04, the php-gd package for ubuntu doesn't use the gd bundles library for security reasons if I understood this correctly. I solved it by downloading a php-gd fedora rpm and converting it to .deb with alien. it works for the apache websites but not for the commandline. I get the follwoing error: php /path/to/process.php variable1 variable2 Warning: Wrong parameter count for strpos() in /path/to/config.php on line 30 JpGraph Error This PHP installation is not configured with the GD library. Please recompile PHP with GD support to run JpGraph. (Neither function imagetypes() nor imagecreatefromstring() does exist)ro does anyone know how to fix this? regards Chantal -- 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] php-gd problems on Ubuntu 8.04
Make sure that your php.ini file for the cli is loading gd. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Chantal Rosmuller wrote: > Hi list, > > I have a PHP problem on Ubuntu 8.04, the php-gd package for ubuntu > doesn't use the gd bundles library for security reasons if I understood > this correctly. I solved it by downloading a php-gd fedora rpm and > converting it to .deb with alien. it works for the apache websites but > not for the commandline. I get the follwoing error: > > > php /path/to/process.php variable1 variable2 > > Warning: Wrong parameter count for strpos() in /path/to/config.php on > line 30 > JpGraph Error This PHP installation is not configured with the GD > library. Please recompile PHP with GD support to run JpGraph. (Neither > function imagetypes() nor imagecreatefromstring() does exist)ro > > does anyone know how to fix this? > > regards Chantal > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php-gd problems on Ubuntu 8.04
Hi list, I have a PHP problem on Ubuntu 8.04, the php-gd package for ubuntu doesn't use the gd bundles library for security reasons if I understood this correctly. I solved it by downloading a php-gd fedora rpm and converting it to .deb with alien. it works for the apache websites but not for the commandline. I get the follwoing error: php /path/to/process.php variable1 variable2 Warning: Wrong parameter count for strpos() in /path/to/config.php on line 30 JpGraph Error This PHP installation is not configured with the GD library. Please recompile PHP with GD support to run JpGraph. (Neither function imagetypes() nor imagecreatefromstring() does exist)ro does anyone know how to fix this? regards Chantal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD - Print Animated GIF
Stephen Pynenburg wrote: > Hey All, > I'm new to the list, but hopefully it's a nice one :) > Anyway, my problem is fairly straightforward, but there doesn't seem > to be anything on it anywhere. When I read an animated GIF with > imagecreatefromgif(), then print it out with imagegif(), the result is > just the first frame of the animation. Hi Stephen see http://www.libgd.org/FAQ_PHP : "please note that PHP has not yet been updated to include support for the animated GIF features that have been added to gd. It will be added in php 5.3 and 6.x" /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD - Print Animated GIF
Hey All, I'm new to the list, but hopefully it's a nice one :) Anyway, my problem is fairly straightforward, but there doesn't seem to be anything on it anywhere. When I read an animated GIF with imagecreatefromgif(), then print it out with imagegif(), the result is just the first frame of the animation. I've googled this to death, and found plenty on how to build your own animated GIFs, but no answers to this issue. Thanks in advance, Stephen
Re: [PHP] GD brush tracing letters
On Sun, Dec 16, 2007 at 7:16 PM, eric cash <[EMAIL PROTECTED]> wrote: > Quick GD question, I'm building a custom CAPTCHA, and I want to 'trace' > random letters (hopefully from a random font) with a brush. Is there an easy > way to do this, or am I going to have to build some ridiculous custom > library on my own to do it? Thanks! You'll need to ask that on a GD list. It's not PHP-related. http://www.libgd.org/Support -- Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD brush tracing letters
Quick GD question, I'm building a custom CAPTCHA, and I want to 'trace' random letters (hopefully from a random font) with a brush. Is there an easy way to do this, or am I going to have to build some ridiculous custom library on my own to do it? Thanks! ec -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD - JPEG to PNG with transparency and color
At 12:16 PM -0400 5/6/08, Travis L. Font wrote: Following files: bg.png - Clear Transparent Image 14416fed5d4f78.jpg - Normal Jpeg Image The Code: header('content-type: image/png'); $watermark = imagecreatefromjpeg('14416fed5d4f78.jpg'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefrompng('bg.png'); $size = getimagesize('bg.png'); $dest_x = $size[0] - $watermark_width - 5; $dest_y = $size[1] - $watermark_height - 5; imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); imagepng($image); imagedestroy($image); imagedestroy($watermark); The Problem: The code above works fine in sense of syntax! bg.png acts as a transparent border for 14416fed5d4f78.jpg to keep the size of bg.png and not the size of 14416fed5d4f78.jpg so it doesn't blow up 14416fed5d4f78.jpg. However, the image comes out black/white and has lost its color! I looked all over Google and I've found nothing so far that's functional to give the new created png file the correct colors as the original 14416fed5d4f78.jpg. I figure that I'm missing some small elements to the process of creating the png Anyone have any ideas, pointers, advice, or correct solution to make this possible? Travis: Try this: $original=imagecreatefromjpeg("mydog.jpg"); $watermark=imagecreatefrompng("copyright.png"); $osx=imagesx($original); $osy=imagesy($original); $wsx=imagesx($watermark); $wsy=imagesy($watermark); imagecopy($original, $watermark, ($osx-$wsx)/2, ($osy-$wsy)/2, 0, 0, $wsx, $wsy); //center imagepng($original, "trans.png"); The code works here: http://webbytedd.com/b/watermark/ Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com
[PHP] GD - JPEG to PNG with transparency and color
Following files: bg.png - Clear Transparent Image 14416fed5d4f78.jpg - Normal Jpeg Image The Code: header('content-type: image/png'); $watermark = imagecreatefromjpeg('14416fed5d4f78.jpg'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefrompng('bg.png'); $size = getimagesize('bg.png'); $dest_x = $size[0] - $watermark_width - 5; $dest_y = $size[1] - $watermark_height - 5; imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); imagepng($image); imagedestroy($image); imagedestroy($watermark); The Problem: The code above works fine in sense of syntax! bg.png acts as a transparent border for 14416fed5d4f78.jpg to keep the size of bg.png and not the size of 14416fed5d4f78.jpg so it doesn't blow up 14416fed5d4f78.jpg. However, the image comes out black/white and has lost its color! I looked all over Google and I've found nothing so far that's functional to give the new created png file the correct colors as the original 14416fed5d4f78.jpg. I figure that I'm missing some small elements to the process of creating the png... Anyone have any ideas, pointers, advice, or correct solution to make this possible? Sincerely, Travis L. Font Interactive Developer BSN 5901 Broken Sound Parkway NW 6th Floor Boca Raton, FL 33487 Main Ph.: 561-994-8335 Ext.737 Fax: 561-998-4635 Toll Free: 1-800-939-4071 Ext.737 http://www.bsnonline.net/ / http://www.endorush.com/ / http://www.tlfapparel.com/ The 27th Fastest Growing Private Company In America* The 2nd Fastest Growing Private Company In The Miami-Fort Lauderdale Metro Region* The 4th Fastest Growing Private Company In The Health Industry* [*Above Rankings Were Determined By Inc. 500/5,000] This e-mail, and any attachment, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, re-transmission, copying, dissemination or other use of this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. The contents of this message may contain personal views which are not the views of BSN.
Re: [PHP] PHP GD library installing
On Apr 10, 2008, at 5:15 PM, Daniel Brown wrote: On Thu, Apr 10, 2008 at 4:54 AM, Luca Paolella <[EMAIL PROTECTED] > wrote: How do I install/activate the GD library with my existing PHP version? I'm quite sure it isn't already, since I got this error: Fatal error: Call to undefined function imagecreate() in /Volumes/Data/Users/luca/Library/WebServer/Documents/reloadTest/ image.php on line 6 First, this is a server to which you have root access, correct? You won't be able to install it otherwise, such as if you're on a shared web host. Secondly, what *NIX are you using? It looks to me like a BSD-style system maybe MacOS? -- Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! Yes, it's Mac OSX and I have root access on the machine; I just checked my mail, so sorry for the delay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP GD library installing
On Thu, Apr 10, 2008 at 4:54 AM, Luca Paolella <[EMAIL PROTECTED]> wrote: > How do I install/activate the GD library with my existing PHP version? I'm > quite sure it isn't already, since I got this error: > > Fatal error: Call to undefined function imagecreate() in > /Volumes/Data/Users/luca/Library/WebServer/Documents/reloadTest/image.php on > line 6 First, this is a server to which you have root access, correct? You won't be able to install it otherwise, such as if you're on a shared web host. Secondly, what *NIX are you using? It looks to me like a BSD-style system maybe MacOS? -- Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP GD library installing
Quoting Robin Vickery <[EMAIL PROTECTED]>: On 10/04/2008, Thijs Lensselink <[EMAIL PROTECTED]> wrote: Quoting Robin Vickery <[EMAIL PROTECTED]>: > On 10/04/2008, Thijs Lensselink <[EMAIL PROTECTED]> wrote: > > > Quoting Luca Paolella <[EMAIL PROTECTED]>: > > > > > > > How do I install/activate the GD library with my existing PHP version? > > > I'm quite sure it isn't already, since I got this error: > > > > > > Fatal error: Call to undefined function imagecreate() in > > > > > /Volumes/Data/Users/luca/Library/WebServer/Documents/reloadTest/image.php > > on > > > line 6 > > > > > > Please forgive my ignorance, and thanks for your help > > > > > > > > > > On windows it's as easy as downloading the dll from pecl4win.php.net. > > > > But from your directory structure i presume you have some sort of *nix > > system. > > So you have to reconfigure and rebuild PHP. > > > > Ouch... first try installing the php gd module through whatever > package manager your *nix distribution uses. For instance, on Ubuntu > linux you'd do: > > sudo aptitude install php5-gd > > Ouch? That's exactly what i added to my post "Make sure GD is installed on the system." Making sure GD is installed on the system is a very sensible thing to do. The "ouch" was aimed at the suggestion that if you're on a *nix system, the course of action is to recompile php. Normally these days you'd just install the gd module (the equivalent of your windows dll) through your package manager. My bad! :) I always compile everything from source -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP GD library installing
On 10/04/2008, Thijs Lensselink <[EMAIL PROTECTED]> wrote: > Quoting Robin Vickery <[EMAIL PROTECTED]>: > > > > On 10/04/2008, Thijs Lensselink <[EMAIL PROTECTED]> wrote: > > > > > Quoting Luca Paolella <[EMAIL PROTECTED]>: > > > > > > > > > > How do I install/activate the GD library with my existing PHP version? > > > > I'm quite sure it isn't already, since I got this error: > > > > > > > > Fatal error: Call to undefined function imagecreate() in > > > > > > > > /Volumes/Data/Users/luca/Library/WebServer/Documents/reloadTest/image.php > > > on > > > > line 6 > > > > > > > > Please forgive my ignorance, and thanks for your help > > > > > > > > > > > > > > On windows it's as easy as downloading the dll from pecl4win.php.net. > > > > > > But from your directory structure i presume you have some sort of *nix > > > system. > > > So you have to reconfigure and rebuild PHP. > > > > > > > Ouch... first try installing the php gd module through whatever > > package manager your *nix distribution uses. For instance, on Ubuntu > > linux you'd do: > > > > sudo aptitude install php5-gd > > > > > > Ouch? That's exactly what i added to my post "Make sure GD is installed > on the system." Making sure GD is installed on the system is a very sensible thing to do. The "ouch" was aimed at the suggestion that if you're on a *nix system, the course of action is to recompile php. Normally these days you'd just install the gd module (the equivalent of your windows dll) through your package manager. -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP GD library installing
Quoting Robin Vickery <[EMAIL PROTECTED]>: On 10/04/2008, Thijs Lensselink <[EMAIL PROTECTED]> wrote: Quoting Luca Paolella <[EMAIL PROTECTED]>: > How do I install/activate the GD library with my existing PHP version? > I'm quite sure it isn't already, since I got this error: > > Fatal error: Call to undefined function imagecreate() in > /Volumes/Data/Users/luca/Library/WebServer/Documents/reloadTest/image.php on > line 6 > > Please forgive my ignorance, and thanks for your help > > On windows it's as easy as downloading the dll from pecl4win.php.net. But from your directory structure i presume you have some sort of *nix system. So you have to reconfigure and rebuild PHP. Ouch... first try installing the php gd module through whatever package manager your *nix distribution uses. For instance, on Ubuntu linux you'd do: sudo aptitude install php5-gd Ouch? That's exactly what i added to my post "Make sure GD is installed on the system." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP GD library installing
On 10/04/2008, Thijs Lensselink <[EMAIL PROTECTED]> wrote: > Quoting Luca Paolella <[EMAIL PROTECTED]>: > > > > How do I install/activate the GD library with my existing PHP version? > > I'm quite sure it isn't already, since I got this error: > > > > Fatal error: Call to undefined function imagecreate() in > > > /Volumes/Data/Users/luca/Library/WebServer/Documents/reloadTest/image.php > on > > line 6 > > > > Please forgive my ignorance, and thanks for your help > > > > > > On windows it's as easy as downloading the dll from pecl4win.php.net. > > But from your directory structure i presume you have some sort of *nix > system. > So you have to reconfigure and rebuild PHP. Ouch... first try installing the php gd module through whatever package manager your *nix distribution uses. For instance, on Ubuntu linux you'd do: sudo aptitude install php5-gd -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP GD library installing
Quoting Luca Paolella <[EMAIL PROTECTED]>: How do I install/activate the GD library with my existing PHP version? I'm quite sure it isn't already, since I got this error: Fatal error: Call to undefined function imagecreate() in /Volumes/Data/Users/luca/Library/WebServer/Documents/reloadTest/image.php on line 6 Please forgive my ignorance, and thanks for your help On windows it's as easy as downloading the dll from pecl4win.php.net. But from your directory structure i presume you have some sort of *nix system. So you have to reconfigure and rebuild PHP. Add the following to the configure line. And rebuild PHP after that. Make sure GD is installed on the system. --with-gd --with-jpeg-dir --with-png-dir -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP GD library installing
How do I install/activate the GD library with my existing PHP version? I'm quite sure it isn't already, since I got this error: Fatal error: Call to undefined function imagecreate() in /Volumes/Data/ Users/luca/Library/WebServer/Documents/reloadTest/image.php on line 6 Please forgive my ignorance, and thanks for your help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD, changing an images pixel color, color matching, fuzzy picture
On Mar 28, 2008, at 7:38 PM, Lamonte <[EMAIL PROTECTED]> wrote: Casey wrote: I have an annoying habit of not using comments :) Explanations are inline. On Mar 28, 2008, at 7:10 PM, Lamonte <[EMAIL PROTECTED]> wrote: Casey wrote: On Mar 28, 2008, at 4:27 PM, Lamonte <[EMAIL PROTECTED]> wrote: Okay I created a script that changes a basic smiley face into a red smiley face..but it doesn't replace all the yellow, it looks like a yellow shadow in the background: $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec (substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH<$height;$cloneH++) { for($x=0;$x<$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header("Content-Type: {$data['mime']}"); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 && $b == $b2 && $g == $g2 ) return true; return false; //echo "$r $r2, $g $g2, $b $b2"; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi! I have absolutely no clue if this will work. This has been typed directly into my mail client, so no guarantees. return array('r' => ($color >> 16) & 0xFF, 'g' => ($color >> 8) & 0xFF, 'b' => $color & 0xFF); } This function returns an array of red, green, and blue from an integer like 0xFF. function toColor($r, $g, $b) { return $r * $g * $b; } This function is basically the opposite of the above. (the integer value from red, green, and blue) $image = 'smiley.png'; list($w, $h) = getimagesize($image); $im = imagecreatefrompng($image); for ($y = 0; $y < $h; $y++) { for ($x = 0; $x < $w; $x++) { Loop through the pixels. extract(toRGB(imagecolorat($im, $x, $y))); Take the values from the array return of toRGB so we can use $r, $g, and $b instead of $array['r'], etc. if ($r >= 0xCC && $g >= 0xCC && $b <= 0x33) After some trial and error (looking at color charts), any red > CC, green > CC, and blue < 33 is some shade of yellow. imagesetpixel($im, $x, $y, toColor(($r + $g) / 2, 0, $b)); The expression inside toColor() is my attempt to calculate the correct shade of red from the shade of yellow. } } header('Content-type: image/png'); imagepng($im); ?> :) I don't understand half of that, can you explain what you did? (it works) I was more trying to "fix" my problem then recoding the whole thing though. I hope that helps. The thing is, it returns black. not red. Oh. Replace the toColor function with the imagecolorallocate function and add $im as the first parameter. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD, changing an images pixel color, color matching, fuzzy picture
I have an annoying habit of not using comments :) Explanations are inline. On Mar 28, 2008, at 7:10 PM, Lamonte <[EMAIL PROTECTED]> wrote: Casey wrote: On Mar 28, 2008, at 4:27 PM, Lamonte <[EMAIL PROTECTED]> wrote: Okay I created a script that changes a basic smiley face into a red smiley face..but it doesn't replace all the yellow, it looks like a yellow shadow in the background: $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec (substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH<$height;$cloneH++) { for($x=0;$x<$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header("Content-Type: {$data['mime']}"); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 && $b == $b2 && $g == $g2 ) return true; return false; //echo "$r $r2, $g $g2, $b $b2"; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi! I have absolutely no clue if this will work. This has been typed directly into my mail client, so no guarantees. return array('r' => ($color >> 16) & 0xFF, 'g' => ($color >> 8) & 0xFF, 'b' => $color & 0xFF); } This function returns an array of red, green, and blue from an integer like 0xFF. function toColor($r, $g, $b) { return $r * $g * $b; } This function is basically the opposite of the above. (the integer value from red, green, and blue) $image = 'smiley.png'; list($w, $h) = getimagesize($image); $im = imagecreatefrompng($image); for ($y = 0; $y < $h; $y++) { for ($x = 0; $x < $w; $x++) { Loop through the pixels. extract(toRGB(imagecolorat($im, $x, $y))); Take the values from the array return of toRGB so we can use $r, $g, and $b instead of $array['r'], etc. if ($r >= 0xCC && $g >= 0xCC && $b <= 0x33) After some trial and error (looking at color charts), any red > CC, green > CC, and blue < 33 is some shade of yellow. imagesetpixel($im, $x, $y, toColor(($r + $g) / 2, 0, $b)); The expression inside toColor() is my attempt to calculate the correct shade of red from the shade of yellow. } } header('Content-type: image/png'); imagepng($im); ?> :) I don't understand half of that, can you explain what you did? (it works) I was more trying to "fix" my problem then recoding the whole thing though. I hope that helps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD, changing an images pixel color, color matching, fuzzy picture
On Mar 28, 2008, at 4:27 PM, Lamonte <[EMAIL PROTECTED]> wrote: Okay I created a script that changes a basic smiley face into a red smiley face..but it doesn't replace all the yellow, it looks like a yellow shadow in the background: $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec (substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH<$height;$cloneH++) { for($x=0;$x<$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header("Content-Type: {$data['mime']}"); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 && $b == $b2 && $g == $g2 ) return true; return false; //echo "$r $r2, $g $g2, $b $b2"; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi! I have absolutely no clue if this will work. This has been typed directly into my mail client, so no guarantees. return array('r' => ($color >> 16) & 0xFF, 'g' => ($color >> 8) & 0xFF, 'b' => $color & 0xFF); } function toColor($r, $g, $b) { return $r * $g * $b; } $image = 'smiley.png'; list($w, $h) = getimagesize($image); $im = imagecreatefrompng($image); for ($y = 0; $y < $h; $y++) { for ($x = 0; $x < $w; $x++) { extract(toRGB(imagecolorat($im, $x, $y))); if ($r >= 0xCC && $g >= 0xCC && $b <= 0x33) imagesetpixel($im, $x, $y, toColor(($r + $g) / 2, 0, $b)); } } header('Content-type: image/png'); imagepng($im); ?> :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD, changing an images pixel color, color matching, fuzzy picture
Okay I created a script that changes a basic smiley face into a red smiley face..but it doesn't replace all the yellow, it looks like a yellow shadow in the background: $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec(substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH<$height;$cloneH++) { for($x=0;$x<$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header("Content-Type: {$data['mime']}"); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 && $b == $b2 && $g == $g2 ) return true; return false; //echo "$r $r2, $g $g2, $b $b2"; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD / Pixel Font Rendering
On Monday 17 March 2008 13:10:20 Jochem Maas wrote: > Børge Holen schreef: > > On Monday 17 March 2008 09:25:36 Jochem Maas wrote: > >> nihilism machine schreef: > >>> I am trying to render an 8 pixel pixel font without anti aliasing to > >>> look crisp (silkscreen) in 8pt with gd. the font is huge and ugly: > >>> > >>> >>> // Set the content-type > >>> header("Content-type: image/png"); > >>> > >>> // Create the image > >>> $im = imagecreatetruecolor(400, 30); > >>> > >>> // Create some colors > >>> $white = imagecolorallocate($im, 255, 255, 255); > >>> $grey = imagecolorallocate($im, 128, 128, 128); > >>> $black = imagecolorallocate($im, 0, 0, 0); > >>> imagefilledrectangle($im, 0, 0, 399, 29, $white); > >>> > >>> // The text to draw > >>> $text = 'Testing...'; > >>> // Replace path by your own font path > >>> $font = 'silkscreen.ttf'; > >>> > >>> // Add some shadow to the text > >>> imagettftext($im, 20, 0, 11, 21, $grey, $font, $text); > >>> > >>> // Add the text > >>> imagettftext($im, 20, 0, 10, 20, $black, $font, $text); > >>> > >>> // Using imagepng() results in clearer text compared with imagejpeg() > >>> imagepng($im); > >>> imagedestroy($im); > >>> ?> > >>> > >>> > >>> -- any ideas? > >> > >> don't post twice. > > > > I recon he didn't. > > maybe, maybe not. I get punished for stuff I didn't do all the time ... why > shouldn't he ;-) THAT on the other hand is a perfectly good reason to kick the shit out of someone =D > > > This list has the tendancy to send double posts from time to time. > > it does? haven't noticed that. I'll be more vigilant (well I'll try) > > >> use '8' instead of '20' for the fontsize. -- --- Børge Holen http://www.arivene.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD / Pixel Font Rendering
Børge Holen schreef: On Monday 17 March 2008 09:25:36 Jochem Maas wrote: nihilism machine schreef: I am trying to render an 8 pixel pixel font without anti aliasing to look crisp (silkscreen) in 8pt with gd. the font is huge and ugly: -- any ideas? don't post twice. I recon he didn't. maybe, maybe not. I get punished for stuff I didn't do all the time ... why shouldn't he ;-) This list has the tendancy to send double posts from time to time. it does? haven't noticed that. I'll be more vigilant (well I'll try) use '8' instead of '20' for the fontsize. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD / Pixel Font Rendering
On Monday 17 March 2008 09:25:36 Jochem Maas wrote: > nihilism machine schreef: > > I am trying to render an 8 pixel pixel font without anti aliasing to > > look crisp (silkscreen) in 8pt with gd. the font is huge and ugly: > > > > > // Set the content-type > > header("Content-type: image/png"); > > > > // Create the image > > $im = imagecreatetruecolor(400, 30); > > > > // Create some colors > > $white = imagecolorallocate($im, 255, 255, 255); > > $grey = imagecolorallocate($im, 128, 128, 128); > > $black = imagecolorallocate($im, 0, 0, 0); > > imagefilledrectangle($im, 0, 0, 399, 29, $white); > > > > // The text to draw > > $text = 'Testing...'; > > // Replace path by your own font path > > $font = 'silkscreen.ttf'; > > > > // Add some shadow to the text > > imagettftext($im, 20, 0, 11, 21, $grey, $font, $text); > > > > // Add the text > > imagettftext($im, 20, 0, 10, 20, $black, $font, $text); > > > > // Using imagepng() results in clearer text compared with imagejpeg() > > imagepng($im); > > imagedestroy($im); > > ?> > > > > > > -- any ideas? > > don't post twice. I recon he didn't. This list has the tendancy to send double posts from time to time. > use '8' instead of '20' for the fontsize. -- --- Børge Holen http://www.arivene.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD / Pixel Font Rendering
nihilism machine schreef: I am trying to render an 8 pixel pixel font without anti aliasing to look crisp (silkscreen) in 8pt with gd. the font is huge and ugly: -- any ideas? don't post twice. use '8' instead of '20' for the fontsize. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD / Pixel Font Rendering
I am trying to render an 8 pixel pixel font without anti aliasing to look crisp (silkscreen) in 8pt with gd. the font is huge and ugly: -- any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD Library
Charlene wrote: > I have the GD Library installed, but I don't see any of the fonts. What > is the preferred location to download fonts (standard fonts like Arial, > Verdana, etc.) and which directory should they be stored in? 'standard fonts' is not. and any directory you want. upload any legal fonts you have/need. http://php.net/manual/en/function.imagettftext.php ... pass it in the fullpath to the .tff file (amongst other things) > > Charlene > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD Library
I have the GD Library installed, but I don't see any of the fonts. What is the preferred location to download fonts (standard fonts like Arial, Verdana, etc.) and which directory should they be stored in? Charlene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] gd with php 5.2.4
Help! I'm using php version 5.2.4 and I'm not able to even get a pointer to a jpg image (ImageCreateFromJPEG(filename)). When I do so the program exits ... Can anybody help me, please? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD Library
I would point you to MAMP: http://www.mamp.info/ It's like Xampp but designed all for a Mac... Easy to install, to configure and to user ;) Regards, Samy Greg Donald schrieb: On Thu, 13 Sep 2007, Steve Marquez wrote: I am running PHP 4.4.7 without the GD Library and need it to run. I am very novice on PHP, and am using a Mac with 10.3.9. Can anyone point me in the right direction? http://destiney.com/blog/php-4-5-macos-x Hopefully those configs aren't totally outdated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD Library
On Thu, 13 Sep 2007, Steve Marquez wrote: > I am running PHP 4.4.7 without the GD Library and need it to run. > I am very novice on PHP, and am using a Mac with 10.3.9. > Can anyone point me in the right direction? http://destiney.com/blog/php-4-5-macos-x Hopefully those configs aren't totally outdated. -- Greg Donald Cyberfusion Consulting http://cyberfusionconsulting.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] GD Library
[snip] I am running PHP 4.4.7 without the GD Library and need it to run. I am very novice on PHP, and am using a Mac with 10.3.9. Can anyone point me in the right direction? [/snip] http://www.php.net/gd tells you how to get and install the libraries. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD Library
Greetings, I am running PHP 4.4.7 without the GD Library and need it to run. I am very novice on PHP, and am using a Mac with 10.3.9. Can anyone point me in the right direction? Thank you so much, -- Steve M.
Re: [PHP] GD Library and outputing image
At 9:17 PM +0100 6/13/07, Ross wrote: Never really used the GD much before very straightforward but how do I output the image on a page. This is fine on a php page on its own but what about one where the headers are already sent? Ross: That's not a problem. See this: http://xn--nvg.com/rotated_text <-- if your browser chokes, get a better browser The image code (text.php) is: and it's called from html like this: If you put this into your site, you'll need arial.tff to make it work, but you can find it in lot's of places. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD Library and outputing image
On 6/13/07, Stephen <[EMAIL PROTECTED]> wrote: Ross <[EMAIL PROTECTED]> wrote:Never really used the GD much before very straightforward but how do I output the image on a page. This is fine on a php page on its own but what about one where the headers are already sent? Save the image as file, first. The href src= etc If space isn't an issue, that's an alternative answer -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD Library and outputing image
Ross <[EMAIL PROTECTED]> wrote:Never really used the GD much before very straightforward but how do I output the image on a page. This is fine on a php page on its own but what about one where the headers are already sent? Save the image as file, first. The href src= etc
Re: [PHP] GD Library and outputing image
On 6/13/07, Ross <[EMAIL PROTECTED]> wrote: Never really used the GD much before very straightforward but how do I output the image on a page. This is fine on a php page on its own but what about one where the headers are already sent? I take it I can do something like this . Anyone got a better method? $image = imagecreatefromjpeg($img_url); if ($image === false) { die ('Unable to open image'); } // Get original width and height echo $width = imagesx($image); echo $height = imagesy($image); // New width and height $new_width = 200; $new_height = 150; // Resample $image_resized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // Display resized image header('Content-type: image/jpeg'); imagejpeg($image_resized); die(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Aside from perhaps changing die(); to exit;, though not necessary, I'd say that it looks like you're right on track. Until you find a better way to have HTML display an image than through , I think it's good to go. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD Library and outputing image
Never really used the GD much before very straightforward but how do I output the image on a page. This is fine on a php page on its own but what about one where the headers are already sent? I take it I can do something like this . Anyone got a better method? $image = imagecreatefromjpeg($img_url); if ($image === false) { die ('Unable to open image'); } // Get original width and height echo $width = imagesx($image); echo $height = imagesy($image); // New width and height $new_width = 200; $new_height = 150; // Resample $image_resized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // Display resized image header('Content-type: image/jpeg'); imagejpeg($image_resized); die(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] GD 2.0.28 + PHP 4.4.2 + pixelation :(
> imagecopyresampled might help you... I use that and it works > without > problems. > Hi Peter, " I have done some searching via google and some answers say change copyimageresampled to copyimageresized etc" I have tried your suggestion with the same results ... that is what I was using first :( S -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD 2.0.28 + PHP 4.4.2 + pixelation :(
Steven Macintyre wrote: > Hi All, > > I have done some searching via google and some answers say change > copyimageresampled to copyimageresized etc which should be the correct; use copyimageresampled() > > I have tried all fixes ... to no avail > > > I have one image here 1280 x 960 (150 dpi) 24 depth DPI is completely irrelevant. the '24 depth' sounds like your using a PNG as input rather that a JPEG (which your function expects) your not making sure that the new width & height are always integers. use intval() or ceil() or floor() (depending on your your and the context)... I have no idea what happens if you pass floats (or non-numeric data) in the relevant arguments of image*() functinons but I'm guessing it *could* lead to unexplained weirdness of some sort. read the man page for imagejpeg(): http://php.net/manual/en/function.imagejpeg.php take note of the third argument, personally I always set it to 100, anything less and clients have a tendency to start complaining about image quality. > > When using the following it pixelates ... > > function createthumb($name,$filename,$new_w,$new_h) > { > $system=explode(".",$name); > $src_img=imagecreatefromjpeg($name); > $old_x=imageSX($src_img); > $old_y=imageSY($src_img); > if ($old_x > $old_y) > { > $thumb_w=$new_w; > $thumb_h=$old_y*($new_h/$old_x); > } > if ($old_x < $old_y) > { > $thumb_w=$old_x*($new_w/$old_y); > $thumb_h=$new_h; > } > if ($old_x == $old_y) > { > $thumb_w=$new_w; > $thumb_h=$new_h; > } > $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); > > imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); try: imagecopyresampled(); > imagejpeg($dst_img,$filename); > imagedestroy($dst_img); > imagedestroy($src_img); > } > > Which I am of course calling with > createthumb($add,'../pics/'.$largeval,350,263); > > Now ... afaik my new sizes are proportional to the big ones ... but it > pixelates :( > > However, > > Using an image 1600 x 1200 (96 dpi) 24 depth it works and there is no > pixilation > > Can someone perhaps assist now? > > > > Kind Regards, > > > Steven Macintyre > http://steven.macintyre.name > -- > > http://www.friends4friends.co.za > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] GD 2.0.28 + PHP 4.4.2 + pixelation :(
Hi, imagecopyresampled might help you... I use that and it works without problems. /Peter -Original Message- From: Steven Macintyre [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 27, 2006 10:17 AM To: php-general@lists.php.net Subject: [PHP] GD 2.0.28 + PHP 4.4.2 + pixelation :( Hi All, I have done some searching via google and some answers say change copyimageresampled to copyimageresized etc I have tried all fixes ... to no avail I have one image here 1280 x 960 (150 dpi) 24 depth When using the following it pixelates ... function createthumb($name,$filename,$new_w,$new_h) { $system=explode(".",$name); $src_img=imagecreatefromjpeg($name); $old_x=imageSX($src_img); $old_y=imageSY($src_img); if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); imagejpeg($dst_img,$filename); imagedestroy($dst_img); imagedestroy($src_img); } Which I am of course calling with createthumb($add,'../pics/'.$largeval,350,263); Now ... afaik my new sizes are proportional to the big ones ... but it pixelates :( However, Using an image 1600 x 1200 (96 dpi) 24 depth it works and there is no pixilation Can someone perhaps assist now? Kind Regards, Steven Macintyre http://steven.macintyre.name -- http://www.friends4friends.co.za -- 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] GD 2.0.28 + PHP 4.4.2 + pixelation :(
Hi All, I have done some searching via google and some answers say change copyimageresampled to copyimageresized etc I have tried all fixes ... to no avail I have one image here 1280 x 960 (150 dpi) 24 depth When using the following it pixelates ... function createthumb($name,$filename,$new_w,$new_h) { $system=explode(".",$name); $src_img=imagecreatefromjpeg($name); $old_x=imageSX($src_img); $old_y=imageSY($src_img); if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); imagejpeg($dst_img,$filename); imagedestroy($dst_img); imagedestroy($src_img); } Which I am of course calling with createthumb($add,'../pics/'.$largeval,350,263); Now ... afaik my new sizes are proportional to the big ones ... but it pixelates :( However, Using an image 1600 x 1200 (96 dpi) 24 depth it works and there is no pixilation Can someone perhaps assist now? Kind Regards, Steven Macintyre http://steven.macintyre.name -- http://www.friends4friends.co.za -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] GD, and GD JPEG
I don't know what environment you are on, because I have been absent from this list a long while. If you are on a Linux distribution you might be able to do this via the command line: yum install php-gd.i386 service httpd restart That might install GD and then restart the web server. /Peter -Original Message- From: sublimenal [mailto:[EMAIL PROTECTED] Sent: Sunday, November 26, 2006 6:31 AM To: php-general@lists.php.net Subject: Re: [PHP] GD, and GD JPEG Hey you need to ./configure it into your php installation via the command line Jeff-153 wrote: > > > Hi there. > I installed a script but it requires GD and GD JPEG > > I downloaded GD, and GD JPEG > > But how the heck do I install it? > > Thanks guys > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- View this message in context: http://www.nabble.com/GD%2C-and-GD-JPEG-tf2705080.html#a7543299 Sent from the PHP - General mailing list archive at Nabble.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
Re: [PHP] GD, and GD JPEG
Hey you need to ./configure it into your php installation via the command line Jeff-153 wrote: > > > Hi there. > I installed a script but it requires GD and GD JPEG > > I downloaded GD, and GD JPEG > > But how the heck do I install it? > > Thanks guys > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- View this message in context: http://www.nabble.com/GD%2C-and-GD-JPEG-tf2705080.html#a7543299 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD.. con't
On Sat, November 25, 2006 4:25 pm, Jeff wrote: > Do I have to compile it with a C program? You do not need to compile GD on Windows, unless you are a masochist. :-v Use http://php.net/phpinfo to find out where you php.ini file is, or should be. Whatever directory that shows for "php.ini", put your php.ini file there. Then edit it and find the line about php_gd.dll, or something like that), and un-comment it by removing the ';' at the beginning. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD.. con't
Do I have to compile it with a C program? What programs do people suggest I use to make PHP Files? Is there a simple C program that will create basically whatever you want to do, without knowing the language? I recall studying it in school, vaguely recalling the code... Thanks, Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD, and GD JPEG
Hi there. I installed a script but it requires GD and GD JPEG I downloaded GD, and GD JPEG But how the heck do I install it? Thanks guys -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD - Problem writing text
On Thu, November 23, 2006 9:30 am, Fredrik Thunberg wrote: > imagettftext ($im, 30, 0, 10, 40 , $black, TTF_DIR. "times.ttf", > "Hello World!"); > FreeType Support enabled > FreeType Linkage with freetype > FreeType Version 2.1.3 > The one things that differs between the servers is: > "FreeType Linkagewith TTF library" is set on the faulty one. > Can > this be the problem? It sure seems suspicious to me. Not that I can ever keep straight all those different font packages, but maybe you need that "other other" TTF library font format instead of times.ttf to be installed on the non-working machine... The only other thing would be to double-check that PHP actually can find and read the full path to your times.ttf file, to be SURE it's not paths/permissions getting you. Oh. Also try to compare any FreeType configuration files on both machines. I seem to recall there was some kind of config file... No, that was the pdflib.upr file I was thinking of... Still, any kind of test/configuration check you can run on the font installations may help. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD - Problem writing text
Hi all This is my first attempt to wrie to this mailing list, so please bare with me. My problem is as follows I'm trying to generate a dynamic picture with some text on it. The code works fine on one of my servers, but not on the other one. The code I'm using: $im = imagecreatetruecolor (400, 100); $black = imagecolorallocate ($im, 0, 0, 0 ); $white = imagecolorallocate ($im, 255, 255, 255 ); imagerectangle ($im,0, 0,399,99 ,$black); imagefilledrectangle ($im,0, 0,399,99 ,$white); imagettftext ($im, 30, 0, 10, 40 , $black, TTF_DIR. "times.ttf", "Hello World!"); header ("Content-type: image/png" ); imagepng ($im); Where TTF_DIR is the complete path to the times.ttf-file (which i've chmodded to 777). This is the gd-info from where it works: GD Support enabled GD Version bundled (2.0.28 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.1.3 GIF Read Support enabled GIF Create Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled XBM Support enabled The one things that differs between the servers is: "FreeType Linkagewith TTF library" is set on the faulty one. Can this be the problem? Cheers /Fredrik Thunberg [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gd for php5 under RH ES4
On Wed, October 11, 2006 1:36 pm, Doug Fulton wrote: > I am trying to use the php gd library (for imagecreate, etc) with php5 > under Red Hat ES4. I tried installing php-gd via webmin (which in > turn, > I see, uses up2date), but get the following error in the apache error > log when restarting: > PHP Warning: PHP Startup: Unable to load dynamic library > '/usr/lib/php4/gd.so' - /usr/lib/php4/gd.so: undefined symbol: > empty_string in Unknown on line 0 > > I don't know if the problem is that php-gd is a php4 library or there > is > something else that I need to install or do. I saw something about > php5-gd, but webmin/up2date can't find anything by this name. > > I have searched for a bit on this without joy; any guidance is > appreciated. I am not a system administrator by training, but am a > longtime Unix programmer, so I can handle reasonably low level > instructions, if necessary. I did post this to a Red Hat list without > any reply so far. The way I see it, you have 2 choices: #1. Convince webmin and/or up2date and/or RedHat to fix their broken installer dependencies. #2. Compile the PHP GD extension, and GD itself probably, from source. Actually, you could dink around some more with up2date to be sure you have GD itself installed first -- That might be the problem, and would be trivial to fix. There are 3 pieces to this puzzle that you must install and also match up version-wise: GD PHP PHP GD extension -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] gd for php5 under RH ES4
I am trying to use the php gd library (for imagecreate, etc) with php5 under Red Hat ES4. I tried installing php-gd via webmin (which in turn, I see, uses up2date), but get the following error in the apache error log when restarting: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php4/gd.so' - /usr/lib/php4/gd.so: undefined symbol: empty_string in Unknown on line 0 I don't know if the problem is that php-gd is a php4 library or there is something else that I need to install or do. I saw something about php5-gd, but webmin/up2date can't find anything by this name. I have searched for a bit on this without joy; any guidance is appreciated. I am not a system administrator by training, but am a longtime Unix programmer, so I can handle reasonably low level instructions, if necessary. I did post this to a Red Hat list without any reply so far. Thanks in advance, Doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] GD to database directly
At 12:36 PM -0500 7/19/06, Jay Blanchard wrote: >[snip] >... some research ... >[/snip] > >So, am I to assume that this issue about storing images in databases is >dead? Yes, it was dead before it started, as it was the last time this issue was discussed. Simply put, there are tradeoffs, but both sides are so entrenched in their beliefs that they find it difficult to acknowledge that. So, as I did, try both and figure out what works for you. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] GD to database directly
[snip] ... some research ... [/snip] So, am I to assume that this issue about storing images in databases is dead? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] GD to database directly
[snip] Kevin, you have more than once pointed out using a RAW format for operating the data system, what exactly do you mean? The database becomes the OS? If so, how do you set that up? It is something that I am not totally familiar with. [/snip] I did some research and went back to Kevin's original statement; [kevin] databases can be stored on RAW partitions, thus eliminating FILE SYSTEM overhead [/kevin] Here is what I found; [quote] raw partition vs filesystem store? > What are pros/cons as far as performance, reliability, and ease of > backup/restore? > > Anyone have any experience running Innodb on raw partition? raw partitions are beneficial only in some old OS/hardware configurations where fsync is extremely slow. In most computers, you only get a < 5 % performance improvement from raw partitions. > Any thoughts as to best filesystem for Innodb? What about pros/cons of > journaled filesystems when in use with Innodb (i.e. transactions)? All major Linux file systems seem to have almost the same performance. [/quote - Heikki Tuuri] Use of MySQL on a RAW partition I limited to InnoDB type; (note the use of 'may' in the quote) [quote] http://dev.mysql.com/doc/refman/5.0/en/innodb-raw-devices.html "You can use raw disk partitions as data files in the shared tablespace. By using a raw disk, you can perform non-buffered I/O on Windows and on some Unix systems without filesystem overhead, which may improve performance." [/quote] [quote] A raw device can be bound to an existing block device (e.g. a disk) and be used to perform "raw" IO with that existing block device. Such "raw" IO bypasses the caching that is normally associated with block devices. Hence a raw device offers a more "direct" route to the physical device and allows an application more control over the timing of IO to that physical device. This makes raw devices suitable for complex applications like Database Management Systems that typically do their own caching. [/quote - SCSI HOWTO] Based on what I read utilizing a RAW would probably require most PHP'ers to reconfigure their systems in major ways, including the database type, disk partitions, etc. I don't know about you, but most would consider Heikki Tuuri an expert on MySQL systems and Tuuri's thoughts indicate that RAW partitions vs. file systems are a wash unless you have fsync problems. It would appear that the only benefit comes from not having the file system doing the caching. [previous statement] There are a lot of us using MySQL (and PostGreSQL) along with PHP and in practice we have found that storing images in the database to be less than ideal from both a performance and backup POV. The reasons range from speed to overhead to ease of use. On our hardware. It not only has to do with storing and retrieving BLOB data, but also things like indexing, OS qwirks and the like. [/previous statement] I still stand by this, and amend by saying that using a RAW partition for database storage is typically beyond the needs of most PHP'ers as it gains nothing in performance and requires that much additional maintenance be performed on the database as well as the OS for maintenance of the RAW partition. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] GD to database directly
[snip] ...a lot of stuff started by my original answer... [/snip] While this has been a fine debate I find that the discussion has deteriorated badly. Can we bring it back on point? There are a lot of us using MySQL (and PostGreSQL) along with PHP and in practice we have found that storing images in the database to be less than ideal from both a performance and backup POV. The reasons range from speed to overhead to ease of use. On our hardware. It not only has to do with storing and retrieving BLOB data, but also things like indexing, OS qwirks and the like. Kevin, you have more than once pointed out using a RAW format for operating the data system, what exactly do you mean? The database becomes the OS? If so, how do you set that up? It is something that I am not totally familiar with. If you are talking about RAW photo data I am familiar with that. As far as backup, I have a routine that backs up my databases AND the images, PDF's, DOC's, and other binary file format items that the data system points to. That wasn't hard to set up, and it is very reliable. I never have a problem with integrity. And finally, benchmarking. There would be three benchmarks to be conducted and concerned with here, as I have stated before; PHP and images in the OS's file system PHP and images in the MySQL database PHP and images in the OS's file system pointed to by data stored in the MySQL database. Usually only two are compared. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD to database directly
This one time, at band camp, "Richard Lynch" <[EMAIL PROTECTED]> wrote: > Assume, for the sake of argument, that your hard drive crashed. > > And your backup tape was invalid. > > And the weekly backup tape is also invalid. > > And, for good measuere, the monthly tape is just so out-of-date, that > recovering from the crashed hard drive actually looks like an > attractive option. In this scenario, it would not matter where your images were stored, however it would be a simple matter of hot swapping one of the raid drives. > > LONGBLOB > > Not big enough. 4GB is big enough for any sane image Kind regards Kevin -- "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD to database directly
Richard Lynch wrote: Given the number of posts here in PHP-General alone, of people getting tripped up by these things, I have concluded that cramming images into the DB is far more trouble than it is worth. It *seems* like a Good Idea until you actually do it for awhile, and then run into all these snags. Oddly enough, I have never run into them. Nor has terraserver which stores hundreds of thousands of images in its db, although not mysql. You may well have the needed skill set. Alas, the sheer number of problem posts here would indicate that that skillset is not the norm. I'll stop advising against images in the DB when you answer all the posts here from the problems it causes. :-) Given the right database, then posting raw data to it is not a problem. I would not classify MySQL as one that one would use or that. Personally I still use the rather crude database called Windows to store binary data and live with the backup and crash problems that involves. Simply because the customers have insisted, and signed to accept that they know the problems - even after showing how much more stable Linux is for the server! At the end of the day, binary data is stored on the disk. Whether it is stored in a 'proper' BLOB page set with an id in the related record or direct on the disk with the file name in the record, it still has to be accessed from the disk in order to use it. None of the existing OS/Database options provide the ideal solution and it is that which needs fixing :) - perhaps in another 100 years when Windows has been replaced with a real operating system ;) -- Lester Caine - G8HFL - L.S.Caine Electronic Services - http://home.lsces.co.uk Model Engineers Digital Workshop - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD to database directly
On Fri, July 14, 2006 9:52 pm, Kevin Waterson wrote: > > >> I'm more concerned about the disaster recovery of a DB from a >> crashed >> hard drive, which has been cluttered up with binary data, making >> data >> recovery. > > One of the greatest benifits of binary DB storage is a single point > of back up > mysqldump db_name > backup.sql -u username -p > It really is as simple as that and no need to bother about referential > integrity when rebuilding, simple > mysql db_name < back.sql -u username -p > > How much easier does it get? Assume, for the sake of argument, that your hard drive crashed. And your backup tape was invalid. And the weekly backup tape is also invalid. And, for good measuere, the monthly tape is just so out-of-date, that recovering from the crashed hard drive actually looks like an attractive option. Your images will make this final last stand not viable. >> Then your field storage size has to be large enough. > > LONGBLOB Not big enough. If it *WAS* big enough, we wouldn't have the posts here asking why their monster image didn't work in their database, and got corrupted. >> Given the number of posts here in PHP-General alone, of people >> getting >> tripped up by these things, I have concluded that cramming images >> into >> the DB is far more trouble than it is worth. >> >> It *seems* like a Good Idea until you actually do it for awhile, and >> then run into all these snags. > > Oddly enough, I have never run into them. Nor has terraserver which > stores > hundreds of thousands of images in its db, although not mysql. You may well have the needed skill set. Alas, the sheer number of problem posts here would indicate that that skillset is not the norm. I'll stop advising against images in the DB when you answer all the posts here from the problems it causes. :-) -- 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
Re: [PHP] GD to database directly
This one time, at band camp, "Richard Lynch" <[EMAIL PROTECTED]> wrote: > I'm more concerned about the disaster recovery of a DB from a crashed > hard drive, which has been cluttered up with binary data, making data > recovery. One of the greatest benifits of binary DB storage is a single point of back up mysqldump db_name > backup.sql -u username -p It really is as simple as that and no need to bother about referential integrity when rebuilding, simple mysql db_name < back.sql -u username -p How much easier does it get? > Then your field storage size has to be large enough. LONGBLOB > Given the number of posts here in PHP-General alone, of people getting > tripped up by these things, I have concluded that cramming images into > the DB is far more trouble than it is worth. > > It *seems* like a Good Idea until you actually do it for awhile, and > then run into all these snags. Oddly enough, I have never run into them. Nor has terraserver which stores hundreds of thousands of images in its db, although not mysql. Kevin -- "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD to database directly
On Thu, July 13, 2006 6:49 pm, Kevin Waterson wrote: > This one time, at band camp, "Richard Lynch" <[EMAIL PROTECTED]> wrote: >> If you've benchmarked on YOUR hardware and have a proven savings, >> fine, post your tests and output. > > Already done in previous threads. Actually, to be pedantic, you've provided a reference to a dead tree magazine, which I don't happen to have... > nowhere do I say the db is faster than file system. Just that various > methods of db access are > faster than others. I fail to see you point here? Do you have one? Yes. If your primary consideration is performance, then you need to test on YOUR hardware with YOUR setup. > I have simply asked a question of those debunking the idea of binary > storage how much > of a performance hit do they think it takes, I have done _my_ > homework, I wonder if > others have? > You are quick to ask for benchmarks. Where are yours? My primary consideration has never been performance. I'm more concerned about the disaster recovery of a DB from a crashed hard drive, which has been cluttered up with binary data, making data recovery. Other considerations are that your DB client/server buffer size has to be large enough to handle the images. Then your field storage size has to be large enough. Given the number of posts here in PHP-General alone, of people getting tripped up by these things, I have concluded that cramming images into the DB is far more trouble than it is worth. It *seems* like a Good Idea until you actually do it for awhile, and then run into all these snags. -- 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
Re: [PHP] GD to database directly
This one time, at band camp, "Richard Lynch" <[EMAIL PROTECTED]> wrote: > If you've benchmarked on YOUR hardware and have a proven savings, > fine, post your tests and output. Already done in previous threads. nowhere do I say the db is faster than file system. Just that various methods of db access are faster than others. I fail to see you point here? Do you have one? I have simply asked a question of those debunking the idea of binary storage how much of a performance hit do they think it takes, I have done _my_ homework, I wonder if others have? You are quick to ask for benchmarks. Where are yours? Kevin -- "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD to database directly
On Thu, July 13, 2006 1:25 pm, Kevin Waterson wrote: > This one time, at band camp, "Richard Lynch" <[EMAIL PROTECTED]> wrote: > > >> It's coming FROM THE FILE SYSTEM. > > databases can be stored on RAW partitions, thus eliminating FILE > SYSTEM > overhead And are you actually doing this, or merely introducing a non-existent scenario? Even on a raw partition, the database still has to do *something* to move the drive heads and read the data. Provide a benchmark with the raw partition, images in DB, compared on equivalent hardware with a static file system approach, by all means. I'm sure you'll prove it provides some performance gain. And it probably has almost nothing to do with any list reader's real-world scenario. -- 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
Re: [PHP] GD to database directly
On Tue, July 11, 2006 11:38 am, Eric Butera wrote: > I don't see a problem with storing images in the DB IF they aren't > going to be continually accessed that way. For example say you have a > script that lets a user upload an image and creates a small, medium, > and large view out of it. Stick the original in the Db and then make > your 3 sizes on the fly and cache the output so they are not > continually created. This way you could down the road re-do all the > sizes if you go through a site redesign or the client chooses they > want them 450 instead of 400. =) And this would be better than just throwing the original in the file system in what way?... I'm sure not seeing a "plus" to having the original images in the DB instead of the file system here. I *just* do not understand why you'd want to cram this ginormous chunk of binary data into the DB. You're NOT going to sort on it. You're NOT going to filter it based on what's in the binary data. There are ZERO functions internal to SQL that can do anything at all useful with the data. Maybe if MySQL had GD integrated, and you could do: SELECT imagescaled(image, 400, 300) FROM images But it doesn't. And you're not the CIA using AI feature recognition to compare the photos in your DB with an SQL function. You're just shuffling data through layer after layer after layer of DB calls so it can sit on the same damned hard drive, clogging up the DB space, and making HD disaster recovery of the data in the DB far far far more difficult. And for what? To avoid a few lines of code in your web application to keep the db and file-system in sync? Puhlease. -- 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