questo è un uso che ne faccio io per aggiungere un bordo e mettere un nome sotto l'immagine
codice:
// $binary sono i dati dell'immagine nel db
$name = "example";
$im = imagecreatefromstring($binary);
$src = $im;
$max_width = 70;
$max_height = 70;
$width = imagesx($src);
$height = imagesy($src);
$aspect_ratio = $width / $height;
$dest_ratio = $max_width / $max_height;
if ($dest_ratio > $aspect_ratio) {
$new_height = $max_height;
$new_width = $max_height * $aspect_ratio;
} else {
$new_width = $max_width;
$new_height = $max_width / $aspect_ratio;
}
$new_width = $new_width >= strlen($name)*6 ? $new_width : strlen($name)*6;
$im = imagecreatetruecolor($new_width+2, $new_height+15);
imageAntiAlias($im, true);
imagecopyresampled ($im, $src, 1, 1, 0, 0, $new_width, $new_height, $width, $height);
$text_color = imagecolorallocate ($im, 255, 153, 0);
imagestring($im, 2, 1, $new_height+2, $name, $text_color);
header ("Content-type: image/png");
imagepng ($im);
imagedestroy ($im);