mrcodex Posted October 13, 2008 Share Posted October 13, 2008 I've read FAQ and tried several things, but can not get this to work ... How get I use several e.g. GD 2 scripts at the same page? like this: <?php $im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'test1', $text_color); header('Content-type: image/jpeg'); imagejpeg($im, NULL, 75); imagedestroy($im); $im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'test2', $text_color); header('Content-type: image/jpeg'); imagejpeg($im, NULL, 75); imagedestroy($im); ?> I'm new at PHP, jumping right from ASP ... rgrds, Link to comment https://forums.phpfreaks.com/topic/128246-solved-several-headers/ Share on other sites More sharing options...
DeanWhitehouse Posted October 13, 2008 Share Posted October 13, 2008 You can't have two images like that. If you must use an if statement or something/ Link to comment https://forums.phpfreaks.com/topic/128246-solved-several-headers/#findComment-664213 Share on other sites More sharing options...
mrcodex Posted October 13, 2008 Author Share Posted October 13, 2008 ah, ok. I appreciate any tips/ example of how I do that Link to comment https://forums.phpfreaks.com/topic/128246-solved-several-headers/#findComment-664478 Share on other sites More sharing options...
kenrbnsn Posted October 13, 2008 Share Posted October 13, 2008 It really depends on how you will be using the generated images. Can you give us a hint? Ken Link to comment https://forums.phpfreaks.com/topic/128246-solved-several-headers/#findComment-664483 Share on other sites More sharing options...
mrcodex Posted October 13, 2008 Author Share Posted October 13, 2008 It's mainly to crop images. I have a chat-script (shoutbox kind) that display the chat-text and image of the user. Now I have locked the size of the user-images, but I want to crop them to get the right aspect/ size for my site. I've found several crop-script, but get stuck on the header-thing. So I thought of trying out a simple GD example first. I want to crop and display them instead of crop and save. thx Link to comment https://forums.phpfreaks.com/topic/128246-solved-several-headers/#findComment-664497 Share on other sites More sharing options...
kenrbnsn Posted October 13, 2008 Share Posted October 13, 2008 You need to use the <img> tag specifying a php script as the src. It can be the same script. Example: <?php if (isset($_GET['im'])) { $im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, $_GET['im'], $text_color); header('Content-type: image/jpeg'); imagejpeg($im, NULL, 75); imagedestroy($im); exit(); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>PHP Image Test</title> </head> <body> <img src="?im=test1"><br><img src="?im=test2"> </body> </html> Ken Link to comment https://forums.phpfreaks.com/topic/128246-solved-several-headers/#findComment-664534 Share on other sites More sharing options...
mrcodex Posted October 14, 2008 Author Share Posted October 14, 2008 Thank you very muchly Ken Link to comment https://forums.phpfreaks.com/topic/128246-solved-several-headers/#findComment-664832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.