Here is a PHP code that writes a string on the bottom of a given image. I want to have the image with the string on it to be saved in a folder. The problem is that this script copies the image without the stamped text. Here is the code:

$imag = "images/5.jpg";
//text to display
$text = "";
$wh = getimagesize($imag);
$width = $wh[0];
$height = $wh[1];
//call image
$im = imageCreateFromJpeg($imag);
//RGB color call and shadow call
$color = imageColorAllocate($im,255,255,255);
$shadow = imageColorAllocate($im,128,128,128);
//assign font
$font = 'arial.ttf';
//assign size
$size = round($width/30);
//shadow param
$xs = ($width * 0.62);
$ys = ($height * 0.98);
//get text startpoints and angle
$x = ($width * 0.61);
$y = ($height * 0.977);
$angle = 30;
//write shadow
//write string
//assign JPG type
Header("Content-type: image/jpg");
//create JPG
//clear memory
//Save in folder
$newfile = "images/55.jpg";
$oldfile = $imag;
if (!copy($oldfile, $newfile)) {
	echo "failed to copy $oldfile...\n";

Recommended Answers

All 3 Replies

1. Use lowercase function names.
2. imagejpeg has a filename parameter, use that to overwrite your original image.

Still not working this code isn't able of creating a copy

//create JPG
$oldfile = $im;
$newfile = "images/56.jpg";
if (!copy($oldfile, $newfile)) {
	echo "failed to copy...\n";
//clear memory
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.