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: ?php Header (Content-type: image/gif); $im = imagecreate (150, 150); $background = ImageColorAllocate ($im, 238, 238, 238); $text_color = ImageColorAllocate ($im, 00, 51, 102);//#036 00 33 66 HEX ImageTTFText ($im, 20, 45, 30, 130, $text_color, arial.ttf, Hello World...); ImageGif ($im); ImageDestroy ($im); ? and it's called from html like this: img src=text.php 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
[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 img scr=get_image.php?url=$img_url/a. 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 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 img scr=get_image.php?url=$img_url/a. 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 IMG SRC=..., 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
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, 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