Forum Moderators: coopster
Thought it might be best to ask here, rather than search for something i dont quite know what to look for.
What i would like to do, is to add a unique identifier to an image each time the page is loaded. Like a voucher number or similiar, so each time the page is loaded with the image on, then that random number changes and the number cannot be repeated (does that make sense?), so if someone loads up and the number is 94, then that number can never appear again.
I have GD library installed so i have access to that for image stuff.
Any help would be appreciated.
//get img from its dir, here we use gif, same with jpeg
$im = imagecreatefromgif('where the img is loaded/img.gif');
//get the image size
$w = imagesx($im);
$h = imagesy($im);
// example
$input="AAAAAAAAA";
// next create that text and position it
$text = imagecreatetruecolor($w, $h);
//example of location: text at the top left
imagestring($text, 5, 0, 0, $input, 0x0000FF);
// merge the two components
//set opacity to 50%
imagecopymerge($im, $text, 0, 0, 0, 0, $w, $h, 50);
// output the new img
header('Content-Type: image/gif');
imagegif($im);
imagedestroy ($text);
imagedestroy($im);
?>
check this one with image quality set at 100 (the max)
<?php
$string = "AAAA";
$dir="../default/";
$id=24;
$ext=".jpg";
$dir=$dir.$id.$ext;
$im = imagecreatefromjpeg("../default/a.jpg");
$orange = imagecolorallocate($im, 18, 252, 161);
$px = (imagesx($im) - 9* strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagejpeg($im, $dir, 100);
// then if needed use copy ()
/*
$src=$b;
$dest="../default/$b.'.jpg' ";
copy($src, $dest);
if(!copy($src, $dest))
{echo"no";}
*/
imagedestroy($im);
?>
got to run ...