Generate a thumbnail $ tx = GetImageSize ($ sample );
If ($ tx [0] <=$ tx [1] and $ tx [1] >=120 ){
$ Height = 120;
$ Width = intval ($ height * $ tx [0]/$ tx [1]);
}
If ($ tx [0] >=$ tx [1] and $ tx [0] >=100 ){
$ Width = 100;
$ Height = intval ($ width * $ tx [1]/$ tx [0]);
}
If ($ tx [0] <100 and $ tx [1] <120 ){
$ Width = $ tx [0];
$ Height = $ tx [1];
}
Makethumb2 ($ sample, $ target, $ width, $ height );
// $ SrcFile: source file
// $ DstFile: target file
// $ DstW: Target Image Width
// $ DTH: height of the target file
Function makethumb2 ($ srcFile, $ dstFile, $ dstW, $ dsomething ){
$ Data = GetImageSize ($ srcFile, & $ info );
Switch ($ data [2]) {
Case 1:
$ Im = @ ImageCreateFromGIF ($ srcFile );
Break;
Case 2:
$ Im = @ ImageCreateFromJPEG ($ srcFile );
Break;
Case 3:
$ Im = @ ImageCreateFromPNG ($ srcFile );
Break;
}
$ SrcW = ImageSX ($ im );
$ SrcH = ImageSY ($ im );
$ Ni = ImageCreate ($ dstW, $ dsomething );
ImageCopyResized ($ ni, $ im, 0, 0, 0, $ dstW, $ dsomething, $ srcW, $ srcH );
ImageJpeg ($ ni, $ dstFile );
// If You Need to output data to the browser, change the previous sentence to ImageJpeg ($ ni );
// If you need images in other formats, you can change the last sentence.
}