Got the image resizer to work by including and external script but now my text doesn't show up at all.
<?php
header("Content-type: image/jpg");
include('imgsize.php');
$insert = imagecreatefromjpeg(resizeImage('image.jpg','','650'));
$im = imagecreate(1300, 800);
$background = imagecolorallocatealpha($im, 255, 255, 255, 127);
imagecolortransparent($insert,imagecolorat($insert,50,50));
$insert_x = imagesx($insert);
$insert_y = imagesy($insert);
$text = "blah blah blah blah";
$text_color = imagecolorallocate($im, 233, 14, 91);
imagecopymerge($im,$insert,0,0,0,0,$insert_x,$insert_y,100);
imagestring($im, 8, 1150, 300, $text, $text_color);
imagejpeg($im,"",100);
?>
imagesize.php:
<?php
// Image Resize Script by Zipline Interactive
// http://www.gozipline.com
// http://www.gozipline.com/42,phpimageresizefunction
// info@gozipline.com
// 02/02/2008
// This will resize an image keeping its height/width aspect ratio if you do not specify a height value.
// USAGE:
// MAINTAIN ASPECT AND SAVE FILE.
// This will create a new files called 'resizedImage.jpg' with a longest side resized to 600px.
// resizeImage('../uploads/uploadedImage.jpg','resizedImage.jpg','600');
// MATIAN ASPECT AND SHOW THE IMAGE IN THE BROWSER.
// No other output can be shown before this image.
// resizeImage('../images/uploadedImage.jpg','','450');
// RESHAPE IMAGE WITH SET SIZES
// This will reshape the image to the set dimensions and save as a jpg file.
// resizeImage('uploadedImage.jpg','../images/resized/resizedImage.jpg','150','150');
function resizeImage($source, $destination = NULL,$wdt, $height = NULL){
if(empty($height)){
// Height is nit set so we are keeping the same aspect ratio.
list($width, $height) = getimagesize($source);
if($width > $height){
$w = $wdt;
$h = ($height / $width) * $w;
$w = $w;
}else{
$w = $wdt;
$h = $w;
$w = ($width / $height) * $w;
}
}else{
// Both width and Height are set.
// this will reshape to the new sizes.
$w = $wdt;
$h = $height;
}
$source_image = @file_get_contents($source) or die('Could not open'.$source);
$source_image = @imagecreatefromstring($source_image) or die($source.' is not a valid image');
$sw = imagesx($source_image);
$sh = imagesy($source_image);
$ar = $sw/$sh;
$tar = $w/$h;
if($ar >= $tar){
$x1 = round(($sw - ($sw * ($tar/$ar)))/2);
$x2 = round($sw * ($tar/$ar));
$y1 = 0;
$y2 = $sh;
}else{
$x1 = 0;
$y1 = 0;
$x2 = $sw;
$y2 = round($sw/$tar);
}
$slate = @imagecreatetruecolor($w, $h) or die('Invalid thumbnail dimmensions');
imagecopyresampled($slate, $source_image, 0, 0, $x1, $y1, $w, $h, $x2, $y2);
// If $destination is not set this will output the raw image to the browser and not save the file
if(!$destination) header('Content-type: image/jpeg');
@imagejpeg($slate, $destination, 75) or die('Directory permission problem');
ImageDestroy($slate);
ImageDestroy($source_image);
if(!$destination) exit;
return true;
}
?>
Any Ideas?