MemphiS Posted December 22, 2007 Share Posted December 22, 2007 I want to have an upload script for images on my site. On each image i wish to write to the image my sites url to rpevent image stealing Thanks Quote Link to comment https://forums.phpfreaks.com/topic/82806-php-images/ Share on other sites More sharing options...
Daniel0 Posted December 22, 2007 Share Posted December 22, 2007 <?php $im = imagecreatefrompng('test.png'); $color_red = imagecolorallocate($im, 255, 0 , 0); imagestring($im, 2, 5, 5, 'From: http://localhost/', $color_red); header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?> Will write a string to the image and output it. Note: This is only for PNG files, you'll have to adjust it for GIF and JPEG files as well. Oh, and regarding your signature: http://www.google.com/search?q=php+write+string+to+image Quote Link to comment https://forums.phpfreaks.com/topic/82806-php-images/#findComment-421121 Share on other sites More sharing options...
helraizer Posted December 22, 2007 Share Posted December 22, 2007 Something along the lines of, <?php //assuming the user uploads a gif $//assuming the user uploads a gif $file = $_POST['file']; $image = imagecreatefromgif($file); // create the image from the gif the user uploaded. For this example it's 200x100 $url = imagecreate(200,20); // create another image that is 200x20 $blue = Imagecolorallocate($url, 50,50,155); // create a blue colour $white = Imagecolorallocate($url, 255,255,255); // create a white colour imagefill($url,200,100, $blue); imagestring($url, 2, 10, 2, "©www.mysite.com", $white); imagecopymergegray($image, $url, 0,80,0,0,200,20,25); header("Content-type: image/gif"); imagegif($image); imagedestroy($image); ?> will suffice. Quote Link to comment https://forums.phpfreaks.com/topic/82806-php-images/#findComment-421124 Share on other sites More sharing options...
MemphiS Posted December 22, 2007 Author Share Posted December 22, 2007 haha eating my own words Hate some of the sites google brings up i dont trust them Thanks for you reply. Thanks helraizer as well Im about to start a upload script for the first time and a bit worried really about making sure everything is safe I;d hate to have my site haxed :s Quote Link to comment https://forums.phpfreaks.com/topic/82806-php-images/#findComment-421127 Share on other sites More sharing options...
helraizer Posted December 22, 2007 Share Posted December 22, 2007 As long as you only allow gif, jpg, png, bmp and images files to upload your site is safe. Quote Link to comment https://forums.phpfreaks.com/topic/82806-php-images/#findComment-421137 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.