Page 1 of 1

image question

Posted: Sun Mar 05, 2006 5:18 pm
by jrucifer
okay, so i'm making thumbnails for a portfolio website, and everything is working perfectly but i have just one question. I am making the thumbnails just a resized portion of the image. The only problem is since the demensions of the image are measured from the top left corner, the thumbnail is always the top portion of the image, so it looks a little weird in repitition. my question is, is there any way to start the image demensions from a random spot, or anywhere besides the top left corner. any help is appreciated. here is the code i am currently using:

Code: Select all

//Thumbnail size
$dest_x = 178; 
$dest_y = 55; 
//Image reduction
$iratio = 3.23;
$widthratio = $width_orig / $iratio;
$heightratio = $height_orig / $iratio;
    if ($width_orig >= $height_orig) { 
        $width_new = $width_orig;
        $height_new = $heightratio;
    } else { 
         $width_new = $width_orig;
        $height_new = $widthratio;
    }
//Generate a new image at the size of the thumbnail 
$thumb = imagecreatetruecolor($dest_x,$dest_y); 
//Copy the original image data to it using resampling 
imagecopyresampled($thumb, $i ,0, 0, 0, 0, $dest_x, $dest_y, $width_new, $height_new); 
//Save the thumbnail 
imagejpeg($thumb, "images/work/$type/thumb_$filename", 80); 
		}

Posted: Sun Mar 05, 2006 5:38 pm
by josh
If your image is X pixels wide and you will be cutting off Y pixels, add 1/2 Y to the offset, if you want it random juse use a random number instead of 0