Okay, I used the code above which by itself it certainly does work just fine but to embed into HTML, well I called the image as was suggested and the image does not display so I must be doing something wrong. I just don't understand how to created and/or resize images and them embed them into HTML/PHP pages so that a user can, for example, selct to save the image.
Hmmmmmmmmmmmmmmmmm.
Follow up question.
<?php
//thumbnail max size
//$size = 100;
//max additional size created by margin
$margin = 10;
//draw a border?
$border = false;
//draw a drop shadow?
//$shadow = true;
//where are the images?
$jpegdir = 'images';
//nothing else to configure
$jpeg = $jpegdir .'/'. $HTTP_GET_VARS['img'];
if($d=getimagesize($jpeg)){
$dim = ($d[1]>$d[0]) ? 1 : 0;
$mod = $size / $d[$dim];
$w = (int) ($d[0] * $mod);
$h = (int) ($d[1] * $mod);
$x = (int)(($size + $margin - $w) / 2);
$y = (int)(($size + $margin - $h) / 2);
//echo "<br>$w x $h";
//echo "<br>$x x $y";
header('Content-type: image/jpeg');
$src = imagecreatefromjpeg($jpeg);
$dst = imagecreate($size+($margin * 2), $size+($margin * 2));
$white = imagecolorallocate($dst,255,255,255);
imagefill($dst,0,0,$white);
if($border){
$black = imagecolorallocate($dst,0,0,0);
imagerectangle($dst,0,0,$size+$margin,$size+$margin,$black);
}
if($shadow){
$lighter = imagecolorallocate($dst,220,220,220);
imagefilledrectangle($dst,($x+3),($y+3),($w+$x+3),($h+$y+3),$lighter);
$light = imagecolorallocate($dst,180,180,180);
imagefilledrectangle($dst,($x+1),($y+1),($w+$x+1),($h+$y+1),$light);
$dark = imagecolorallocate($dst,140,140,140);
imagefilledrectangle($dst,($x),($y),($w+$x),($h+$y),$dark);
}
//imagecopyresampled($dst,$src,$x,$y,0,0,$w,$h,$d[0],$d[1]);
imagecopyresized($dst,$src,$x,$y,0,0,$w,$h,$d[0],$d[1]);
imagejpeg($dst);
imagedestroy($dst);
imagedestroy($src);
$fp=fopen("temp.jpg","wb");
fputs($fp,$dst,strlen($dst));
fclose($fp);
}
Why does this not properly save the image that is rendered? I pass the appropriate arg's in and the image does appear resized as needed on the screen. The saved file is not properly formatted though. What am I missing?
[/COLOR]