Jump to content

Php Images


MemphiS

Recommended Posts

<?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 :P

Link to comment
https://forums.phpfreaks.com/topic/82806-php-images/#findComment-421121
Share on other sites

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.

 

Link to comment
https://forums.phpfreaks.com/topic/82806-php-images/#findComment-421124
Share on other sites

haha eating my own words :P  Hate some of the sites google brings up i dont trust them :P 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 :P I;d hate to have my site haxed :s

Link to comment
https://forums.phpfreaks.com/topic/82806-php-images/#findComment-421127
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.