trouble with jpeg output
Posted: Thu Aug 02, 2007 7:22 pm
for some reason, when i switched everything from working with png files to jpegs, all of the sudden i get an output of the web address of the file i am running. can someone help? by the way, the script is designed to take several images and several pieces of text and merge them together, as in an id.
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['first_name'] . " " . $row['last_name'];
$string3 = $row['region'];
$string4 = $row['language'];
$string5 = $row['greeting'];
$string6 = $row['email'];
$id_num = "ID# " . $row['id'];
$pix = $row['pix'];
header("Content-type:image/jpg");
$im = imagecreatetruecolor('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);
// The pic file
// Set a maximum height and width
$width = 116;
$height = 165;
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($pix);
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 = imagecreatetruecolor($pix);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagecopymerge($im, $image_p, 20, 67, 0, 0, $width, $height, 100);
imagecopymerge($im, $logo, 10, 137, 0, 0, 56, 56, 100);
// Output
imagejpeg($im);
?>