|
I use this to function to resize to an image file....
function resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual)
{
/* Get the dimensions of the source picture */
$picsize=getimagesize("$sourcefile");
$source_x = $picsize[0];
$source_y = $picsize[1];
$source_id = imageCreateFromJPEG("$sourcefile");
/* Create a new image object (not neccessarily true colour) */
$target_id=imagecreatetruecolor($dest_x, $dest_y);
/* Resize the original picture and copy it into the just created image
object. Because of the lack of space I had to wrap the parameters to
several lines. I recommend putting them in one line in order keep your
code clean and readable */
$target_pic=imagecopyresampled($target_id,$source_ id, 0,0,0,0, $dest_x,$dest_y, $source_x,$source_y);
/* Create a jpeg with the quality of "$jpegqual" out of the
image object "$target_pic".
This will be saved as $targetfile */
imagejpeg ($target_id,"$targetfile",$jpegqual);
return true;
}
//now need to set images sizes....eg
$largex=600;
$largey=450;
$thumbx=120;
$thumby=90;
//now resize file...in my case $filenamelarge is the name of the move_uploaded_file
resizeToFile ($filenamelarge, $newx, $newy, $destfilename, 90);
resizeToFile ($filenamelarge, $newxb, $newyb, $destfilenameb, 100);
...hope it helps, can post the full script if you want...
G
|