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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.