Page 1 of 1

Image Output Fixed

Posted: Sun Aug 05, 2007 1:26 pm
by bluesguitarman25
the multi-layered txt-pic-merge script is fixed. This is a great script for creating images like ID's on the fly:

Code: Select all

mysql_select_db(user_info);
$id = $_POST['email'];
$sql2 = "SELECT * FROM user_info WHERE email ='$id'";
$result = mysql_query($sql2) or die(mysql_error());
$row = mysql_fetch_assoc($result);
if (!$row) {
echo "<br />Nothing to print....";
}

$string = "DOB:     " . $row['dob'];
$string2 = $row['firstname'] . " " . $row['lastname'];
$string3 = $row['region'];
$string4 = $row['language'];
$string5 = $row['greeting'];
$string6 = $row['email'];
$id_num = "ID#  " . $row['id'];
$pix = $row['pix'];

header("Content-type:image/jpeg");
$im     = imagecreatefromjpeg('citizen-blank.jpg');
$logo = imagecreatefromgif('citizen-logo.gif');
$orange = imagecolorallocate($im, 220, 210, 60);
$black = imagecolorallocate($im, 0, 0, 0);
// next line = bg image, font size, x,y, string, color
// set ($im, 5, 20, 30...) for ID#
imagestring($im, 2, 157, 70, $string, $black);
imagestring($im, 2, 157, 80, $string2, $black);
imagestring($im, 2, 157, 90, $string3, $black);
imagestring($im, 2, 157, 100, $string4, $black);
imagestring($im, 2, 157, 110, $string5, $black);
imagestring($im, 2, 157, 120, $string6, $black);
imagestring($im, 5, 10, 30, $id_num, $orange);

// insert upload image here

// The pic file

// Set a maximum height and width
$width = 116;
$height = 165;

// Get new dimensions
list($width_orig, $height_orig) = getimagesize($pix) or die("could not get image dimensions");
if ($width && ($width_orig < $height_orig)) {
    $width = ($height / $height_orig) * $width_orig;
} else {
    $height = ($width / $width_orig) * $height_orig;
}

// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($pix);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig) or die("could not resample");
imagecopymerge($im, $image_p, 20, 67, 0, 0, $width, $height, 100);
imagecopymerge($im, $logo, 10, 137, 0, 0, 56, 56, 100);

// Output
imagejpeg($im);

Posted: Sun Aug 05, 2007 6:47 pm
by Ollie Saunders
Are you asking a question?

Posted: Sun Aug 05, 2007 6:48 pm
by thiscatis
I think this should have been a reply on another topic

Posted: Sun Aug 05, 2007 6:49 pm
by John Cartwright
thiscatis wrote:I think this should have been a reply on another topic
Yea I believe so.

Topic Locked.