"Johan" <me@knoware.n l> writes:
[color=blue]
> Where to find a php script to upload jpg files and make thumbnails of the
> jpg files ?[/color]
DOn't have the complete thing, but here a few functions to help:
# Function CreateThumbnail - creates the thumbnail version
# of a photo at a fixed size (81 high and correct width)
# INPUT - sourcefile name, targetfile name (thumbnail)
# OUTPUTS - new file in targetfile location
# RETURNS - 0 on success, message otherwise
#
function CreateThumbnail ($sourcefile, $targetfile) {
$desiredY = 81;
// Get the dimensions of the source picture
$picsize=getima gesize("$source file");
if ($picsize == false) { // failed
return("Could not get size on picture $sourcefile");
}
if ($msg = ResizeToFile($s ourcefile, $newX, $newY, $targetfile)) {
return("Resize failed to targetfile: $targetfile ($msg)");
}
return(0);
} // end function CreateThumbnail
/* Function: resizeToFile resizes a picture and writes it to the harddisk
*
* $sourcefile = the filename of the picture that is going to be resized
* $dest_x = X-Size of the target picture in pixels
* $dest_y = Y-Size of the target picture in pixels
* $targetfile = The name under which the resized picture will be stored
* $jpegqual = The Compression-Rate that is to be used
*/
function ResizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual=60)
{
/* Get the dimensions of the source picture */
$picsize=getima gesize("$source file");
if ($picsize == false) {
return("Could not get size on file: $sourcefile\n") ;
}
if (! $source_id) {
return("Could not create image from jpeg file: $sourcefile\n") ;
}
/* Create a new image object (not neccessarily true colour) */
$target_id=imag ecreatetruecolo r($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=ima gecopyresampled ($target_id,$so urce_id,
0,0,0,0,
$dest_x,$dest_y ,
$source_x,$sour ce_y);
/* Create a jpeg with the quality of "$jpegqual" out of the
image object "$target_pi c".
This will be saved as $targetfile */
$stat = imagejpeg ($target_id,"$t argetfile" ,$jpegqual);
if (! $stat) {
return("Failed to create new image file: $targetfile");
}
return 0;
} // end function ResizeToFile
--
John
_______________ _______________ _______________ _______________ _______
John Murtari Software Workshop Inc.
jmurtari@follow ing domain 315.635-1968(x-211) "TheBook.Co m" (TM)
Here are some scripts I have written to dynamically build a HTML table of
thumbnails & insert it as an OBJECT element in the page from which it is
called.
The top-level page contains JavaScript to create the OBJECT element:
<script LANGUAGE="JavaS cript1.2">
OutStr = '<object type="text/html" data="BuildThum bnailGrid.php?w in_width='
+ GetWinWidth() + '&img_width=100 &border_width=0 &cell_space= 40" width="100%"
height="100%" border=0>If you are reading this your browser doesn’t
support Object element...opros tite.'
document.write( OutStr);
document.write( '</object>');
</script>
You can use this JS function to find out how wide your browser window is,
otherwise just enter no. of pixels:
The OBJECT element calls the BuildThumbnailG rid.php script, which in turn
finds all the *.JPG files in the current directory (or whichever you
specify) and calls MakeThumbnail.p hp to make a thumbnail on the fly.
File BuildThumbnailG rid.php:
-----------------------------
<?php
// Pass available window width as win_width using HTTP GET method
// Pass thumbnail width as img_width HTTP GET method
// Pass table border width as border_width using HTTP GET method
// Pass cell padding as cell_pad using HTTP GET method
// Pass cell spacing width as cell_space using HTTP GET method
// Calculate no. of columns that will fit window
$num_cols = floor(($win_wid th - $cell_space)/($img_width + $cell_space)) -
1;
$curr_col = 0; //Set column counter to zero
"Johan" <me@knoware.n l> wrote in message
news:10rh3nvfgp bik5d@corp.supe rnews.com...[color=blue]
> Hi,
>
> Where to find a php script to upload jpg files and make thumbnails of the
> jpg files ?
>
> Johan
>
>[/color]
Comment