mkthumb4.php to HTML

index

USE AT OWN RISK

Generated: Tue Jul 31 15:22:11 2007 from mkthumb4.php 2007/07/12 23.9 KB bytes.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Language"
 content="en-us">
<title>Image Resizing</title>
<meta http-equiv="Content-Type"
 content="text/html; charset=us-ascii">
<link rel="stylesheet"
 type="text/css"
 href="home.css">
</head>
<body>
<h1><a name="top"
 id="top"></a>Image Resizing</h1>

<p class="ctr"><a href="home2.htm">home</a>
</p>

<?php

/* mkthumb4.php

 AIM: Process a FOLDER, finding JPEG image files,
 Check if a file contains a thumbnail image
 If YES, extract and write to disk, AND
 try to COPY the jpeg, WITHOUT all the EXIF info, and
 write that to disk also ... check size of new file
 If it contains NO THUMB, then generate one, and write
 that to disk ...
 NOTE: Uses PHP built-in functions and does NOT require
 any tool kit! But does need EXIF enabled in PHP
 1. Set the $maindir, as the INPUT FOLDER
 2. Set the $path_out, as the OUPTUT FOLDER
 3. Allow name change in-to-out
 4. Preview, and ASK ok?
 Geoff McLane - 15 January, 2006
 see imginfo2.php just for image information, and genimgs01.php to build smaller images
 and genimgs01.php to generate just ONE size output
   2006.07.29 - exclude FP special directories ...
   24/06/2007 - tidy up - write THUMB-t.jpg, NORMAL-n.jpg and FULL-f.jpg
   Prepare a TABLE of THUMBS with links to the NORMAL.
   Each NORMAL has a LINK to the FULL SIZE IMAGE.
 */

// ############################################
$timestart = getmicrotime(); // get time array secs and usecs ...
$maindir = 'temp';
//$maindir = 'C:\Documents and Settings\Geoff McLane\My Documents\My Pictures\Nikon\20070622';
//$maindir = 'C:\Documents and Settings\Geoff McLane\My Documents\Carla\imgs01';
//$maindir = 'C:\HOMEPAGE\P26\fg';
//$maindir = "c:/HOMEPAGE/Max5/images" ; //change this to what ever directory needs scanning
//$maindir = "c:/HOMEPAGE/P26/mona" ; //change this to what ever directory needs scanning
//$maindir = 'C:/HOMEPAGE/P26/antony';
//$maindir = 'C:/HOMEPAGE/Max5/download';
$excl_dir = array('_vti_cnf', '_derived', '_private', '_vti_pvt');

//$path_out = 'pas2007';
//$path_out = 'images';
$path_out = 'temp';

$IN_NM = "/^dscn0/";   // already converted to lowercase before 'match', thus no //i needed!
$CHG_NM = 'pas0607_';
$do_nm_chg = 0;

$resize_img = 512; // RE-SIZE each image to this SIZE
$quality = 95; // was 75, default IJG
$meol = "\r\n";
$thumb_size = 160;   // generate THUMB of this, IF NONE IN IMAGE
$recursive = 0;   // set to 1 to RECURSIVELY read folders

// program variables
$inp_file = '';
$total_size = 0; // total in file size = bytes processed
$total_th = 0; // total of thumbs written
$total_new = 0; // total of NEW files created
$diff_plus = 0;
$diff_minus = 0;
$with_thumb = 0;
$without_th = 0;
$file_count = 0;
$dir_arr = array();
$skipped = array();

// store EACH generated file in an ARRAY
$thumbs = array();
$normal = array();
$fullsz = array();
$titles = array();   // new file titles
$orgname = array();   // original UPPERCASE FILE NAME, and SIZE (x,y)

$imgcnt = 0;
$wrap = 5;
$wcnt = 0;
// debug outputs
$addoriginal = 0;   // set to ADD original image
$addthumb = 0;   // set to ADD (additional) thumb output
$addnormal = 0;   // set to add (additional) normal image
$addfullsz = 0;   // set to add (additional) FULL SIZE image ..
$show_in_file = 0;   // show DEBUG TEXT - full in_file name

if ( ! is_dir( $path_out ) ) {
   echo "ERROR: Path out of $path_out does NOT exist ... aborting ... $meol";
   exit(4);
}
echo "<p>Processing $maindir ...$meol";
echo "<br>$meol";
ProcessDir($maindir);

echo "Got ".count($dir_arr)." directories, from the search ...$meol";
echo "<br>$meol";
if( count($skipped) ) {
   echo "Skipped ".count($skipped)." folders ...$meol";
   echo "<br>$meol";
}
echo "Quality set at $quality ...$meol";
echo "<br>$meol";
echo "Processed $file_count jpg files, total $total_size bytes ...$meol";
echo "<br>$meol";
echo "Processed $with_thumb with thumbs, and $without_th without thumbs ...$meol";
echo "<br>$meol";
echo "Total $total_th bytes in thumbs, and total $total_new bytes in new files ... tot =";
echo ($total_th + $total_new) . " bytes.$meol";
echo "<br>$meol";
echo "Positive difference = $diff_plus, and negative difference = $diff_minus ... sum = ";
echo ($diff_plus + $diff_minus) . "</p>$meol";
echo "$meol";

// store EACH generated file in an ARRAY
// $thumbs = array();
// $normal = array();
// $fullsz = array();
$imgcnt = count($thumbs);
$wcnt = 0;
echo "<p align=\"center\"><a name=\"thumbs\"$meol";
echo " id=\"thumbs\"></a>Table of THUMB images, with links to normal size image, which, if clicked, will$meol";
echo " load the full size image into the browser.</p>$meol";
echo "$meol";
echo "<table summary=\"set of images\">$meol";
for ($i = 0; $i < $imgcnt; $i++)
{
   if ($wcnt == 0) {
   echo "<tr>$meol";
   }
   echo "<td>";
   echo "<a href=\"#" . $titles[$i] . "\">";
   echo "<img src=\"" . $thumbs[$i] . "\"$meol";
   echo " alt=\"thumb image # " . ($i + 1) . "\"></a>$meol";
   echo "</td>$meol";

   $wcnt++;
   if ($wcnt >= $wrap) {
   echo "</tr>$meol";
   echo "$meol";
   $wcnt = 0;
   }
}
if ($wcnt && ($wcnt < $wrap)) {
   while ( $wcnt < $wrap ) {
   echo "<td>";
   echo "No image";
   echo "</td>$meol";
   $wcnt++;
   }
   echo "</tr>$meol";
   $wcnt = 0;
}
echo "</table>$meol";
echo "$meol";

for ($i = 0; $i < $imgcnt; $i++)
{
   echo "<p align=\"center\"><a name=\"" . $titles[$i] . "\"$meol";
   echo " id=\"" . $titles[$i] . "\"></a>";
   echo "<a href=\"" . $fullsz[$i] ."\"$meol";
   echo " target=\"_blank\">";
   echo "<img src=\"" . $normal[$i] . "\"$meol";
   echo " alt=\"normal image # " . ($i + 1) . "\">";
   echo "</a>$meol";
   //echo "<br>" . $orgname[$i][0] . " " . $orgname[$i][1] . " <a href=\"#thumbs\">thumbs</a>$meol";
   echo "<br>$meol";

   echo $titles[$i] . " (" . $orgname[$i][0] . ") " . $orgname[$i][1] . " <a href=\"#thumbs\">thumbs</a>";
   echo "</p>$meol";
   echo "$meol";
}
$timeend = getmicrotime();
$time = $timeend - $timestart;
echo "<p>Script ran for $time seconds ...</p>$meol";

// ############################################

// ###########################################
// Functions used below
// ###########################################
// only KEEP alpha-numeric values
function get_ascii_only($file)
{
   $chrs = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S' ,'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
   '-', '_', '.');
   $imx = strlen($file);
   for($i = 0; $i < $imx; $i++) {
   if( ! in_array($file[$i], $chrs) ) {
   $file[$i] = '_';
   }
   }
   return $file;
}

// ProcessFile( string input_file, string output_path, string out_name )
// store EACH generated file in an ARRAY
// $thumbs = array();
// $normal = array();
// $fullsz = array();
function ProcessFile( $in_file, $out_path, $out_file, $fn ) {
   global $meol;
   global $total_size; // total in file size = bytes processed
   global $total_th; // total of thumbs written
   global $total_new; // total of NEW files created
   global $diff_plus, $diff_minus, $with_thumb, $without_th;
   global $quality;
   global $resize_img;
   global $thumbs, $normal, $fullsz, $titles, $orgname;
   global $addoriginal, $addthumb, $addnormal, $addfullsz;
   global $show_in_file;
   global $thumb_size;
   if ( !file_exists( $in_file ) ) {
   echo "ERROR: Can NOT locate file '$in_file' ... returning ...$meol";
   //exit(1);
   return;
   }
   if ($show_in_file) {
   echo "Got IN file $in_file, OUT-PATH $out_path OUT_FILE $out_file ...$meol";
   }
   $th_size = 0;
   $new_size = 0;
   $file_size = filesize( $in_file );
   // separate path and filename
   $parts = split("/", $in_file);
   $pc = count($parts);
   if( $pc > 1 ) {
   $file_name = $parts[$pc-1]; // last part is FILE NAME
   $patha = array_slice($parts,0,$pc-1); // get array of parts, excluding last ...
   $file_path = implode( "/", $patha);
   } else {
   $file_name = $parts[$pc-1]; // get FILE NAME
   $file_path = ".";
   }
   // echo "Got path of '$file_path', and file name of '$file_name' ...size = $file_size bytes<br>$meol";
   // separate file name and extention
   //$parts = split("\.", $file_name);
   $parts = split("\.", $out_file);
   $pc = count($parts);
   if( $pc > 1 ) {
   $file_ext = $parts[$pc-1]; // last part is FILE NAME
   $filea = array_slice($parts,0,$pc-1);
   $file_tit = implode( ".", $filea );
   } else {
   $file_tit = $file_name;
   $file_ext = "";
   }
   $file_tit = get_ascii_only($file_tit);
   // got ORIGINAL file size, name, and extension
   echo "Got file title '$file_tit', extension '$file_ext' ... size = $file_size bytes.$meol";
   echo "<br>$meol";
   if (strtolower( $file_ext ) != 'jpg') {
   echo "ERROR: NOT a JPG file $fn ... returning ...$meol";
   echo "<br>$meol";
   //exit(2);
   return;
   }

   // LOAD IN JPG FILE FROM FULL FILE PATH
   $src_img = imagecreatefromjpeg("$in_file");
   // $src_img = LoadJpeg("$in_file");
   if ( !$src_img ) {
   echo "ERROR: FAILED to load JPEG image $fn ... returning ...$meol";
   echo "<br>$meol";
   //exit(3);
   return;
   }
   // get it's height and width
   $imgSx = imagesx($src_img);
   $imgSy = imagesy($src_img);
   if( ($imgSx == 0) || ($imgSy == 0) ) {
   echo "ERROR: FAILED to get image size! $fn ... returning ...$meol";
   echo "<br>$meol";
   //exit(4);
   return;
   }
   $ratio = $imgSx/$imgSy;
   echo "Loaded '$fn', of size $imgSx X $imgSy ...ratio = $ratio.$meol";
   echo "<br>$meol";

   $thumb_name = $out_path . '/' . $file_tit . '-t.' . $file_ext;
   $new_name = $out_path . '/' . $file_tit . '-n.' . $file_ext;
   $full_name = $out_path . '/' . $file_tit . '-f.' . $file_ext;

   // put each into appropriate arrays
   $thumbs[] = $thumb_name;
   $normal[] = $new_name;
   $fullsz[] = $full_name;
   $titles[] = $file_tit;
   // $orgname[] = $fn;
   $narr = array();
   $narr[] = $fn;
   $narr[] = "$imgSx X $imgSy";
   $orgname[] = $narr;
   // see if there is ALREADY a thumbnail image embedded ...
   $thumb_data = exif_thumbnail($in_file, $in_width, $in_height, $in_type);
   if ( $thumb_data ) { // PROCESS THUMB DATA
   // separate the FILE into two - thumb and full, and write NORMAL
   $with_thumb++;
   echo "Got thumbnail image $in_width X $in_height ($in_type) ...$meol";
   echo "<br>$meol";

   $fp = fopen("$thumb_name","wb");
   fputs($fp,$thumb_data);
   fclose($fp);
   $th_size = filesize($thumb_name);
   print "Embedded Thumbnail IMAGE written to disk, as '$thumb_name' ... size = $th_size.$meol";
   echo "<br>$meol";

   if ($addthumb) {
   print "<img src='$thumb_name'>$meol";
   echo "<br>$meol";
   }
   // if ( $resize_img && (($imgSx > $resize_img)||($imgSy > $resize_img))) {
   if ( $resize_img ) {
   if($ratio > 1) {
   $new_ix = $resize_img;
   $new_iy = round($resize_img / $ratio);
   } else {
   $new_ix = round($resize_img * $ratio);
   $new_iy = $resize_img;
   }
   print "New NORMAL sizes $new_ix x $new_iy ...$meol";
   echo "<br>$meol";

   $dst_img2 = imagecreatetruecolor($new_ix,$new_iy);
   if ($dst_img2) {
   if ( ImageCopyResampled($dst_img2,$src_img,0,0,0,0,$new_ix,$new_iy,$imgSx,$imgSy) ) {
   if ( imageJpeg($dst_img2,$new_name) ) {
   $new_size = filesize($new_name);
   $diff_size = $file_size - ($th_size + $new_size);
   echo "New written to $new_name - New size = $new_size bytes - diff = $diff_size.$meol";
   echo "<br>$meol";

   if ($addnormal || $addoriginal) {
   print "<table><tr>$meol";
   if ($addnormal) {
   print "<td><img src='$new_name'></td>$meol";
   }
   if ($addoriginal) {
   print "<td><img src='$in_file'></td>$meol";
   }
   print "</tr></table>$meol";
   }
   } else {
   echo "WARNING: 1.Resizing of $in_file FAILED!$meol";
   echo "<br>$meol";
   }
   } else {
   echo "WARNING: 2.Resizing of $in_file FAILED!$meol";
   echo "<br>$meol";
   }
   imagedestroy($dst_img2);
   } else {
   echo "WARNING: 3.Resizing of $in_file FAILED!$meol";
   echo "<br>$meol";
   }
   }
   } else {
   $without_th++;
   echo "Note: No thumbnail image embedded in this JPEG file ...$meol";
   echo "<br>$meol";

   if($ratio > 1) {
   $new_imgSx = $thumb_size;
   $new_imgSy = round($thumb_size / $ratio);
   } else {
   $new_imgSx = round($thumb_size * $ratio);
   $new_imgSy = $thumb_size;
   }
   print "New THUMB sizes $new_imgSx x $new_imgSy ...$meol";
   echo "<br>$meol";

   $dst_img = imagecreatetruecolor($new_imgSx,$new_imgSy);
   if ($dst_img) {
   /* create the scaled instance */
   if ( ImageCopyResampled($dst_img,$src_img,0,0,0,0,$new_imgSx,$new_imgSy,$imgSx,$imgSy) ) {
   /* write to disk */
   if ( imageJpeg($dst_img,"$thumb_name") ) {
   $th_size = filesize($thumb_name);
   print "Thumbnail IMAGE written to disk, as '$thumb_name' ... size = $th_size.$meol";
   echo "<br>$meol";

   if ($addthumb) {
   print "<img src='$thumb_name'>$meol";
   echo "<br>$meol";
   }
   // if ( $resize_img && (($imgSx > $resize_img)||($imgSy > $resize_img))) {
   if ( $resize_img ) {
   if($ratio > 1) {
   $new_ix = $resize_img;
   $new_iy = round($resize_img / $ratio);
   } else {
   $new_ix = round($resize_img * $ratio);
   $new_iy = $resize_img;
   }
   print "New NORMAL sizes $new_ix x $new_iy ...$meol";
   echo "<br>$meol";

   $dst_img2 = imagecreatetruecolor($new_ix,$new_iy);
   if ($dst_img2) {
   if ( ImageCopyResampled($dst_img2,$src_img,0,0,0,0,$new_ix,$new_iy,$imgSx,$imgSy) ) {
   if ( imageJpeg($dst_img2,$new_name) ) {
   $new_size = filesize($new_name);
   $diff_size = $file_size - ($th_size + $new_size);
   echo "New written to $new_name - New size = $new_size bytes - diff = $diff_size$meol";
   echo "<br>$meol";

   if ($addnormal || $addoriginal) {
   print "<table><tr>$meol";
   if ($addnormal) {
   print "<td><img src='$new_name'></td>$meol";
   }
   if ($addoriginal) {
   print "<td><img src='$in_file'></td>$meol";
   }
   print "</tr></table>$meol";
   }
   } else {
   echo "WARNING: 1.Resizing of $in_file FAILED!$meol";
   echo "<br>$meol";
   }
   } else {
   echo "WARNING: 2.Resizing of $in_file FAILED!$meol";
   echo "<br>$meol";
   }
   imagedestroy( $dst_img2 );
   } else {
   echo "WARNING: 3.Resizing of $in_file FAILED!$meol";
   echo "<br>$meol";
   }
   }
   } else {
   echo "WARNING: imagejpeg(...) FAILED ... $meol";
   echo "<br>$meol";
   }
   } else {
   echo "WARNING: ImageCopyResampled FAILED ...$meol";
   echo "<br>$meol";
   }
   imagedestroy( $dst_img );
   } else {
   echo "WARNING: FAILED to create new thumb image ...$meol";
   echo "<br>$meol";
   }
   }
   // NO RE-SIZING - WRITE OUT THE FULL SIZE IMAGE (w/out EXIF, if any)
   $new_jpeg = imagecreatetruecolor($imgSx, $imgSy); /* Create a black image */
   if ( !$new_jpeg ) {
   echo "WARNING: FAILED to create new image ... $meol";
   echo "<br>$meol";
   } else {
   if( imagecopy($new_jpeg,$src_img,0,0,0,0,$imgSx,$imgSy) ) {
   if( imagejpeg( $new_jpeg, $full_name, $quality ) ) {
   $new_size = filesize($full_name);
   $diff_size = $file_size - ($th_size + $new_size);
   echo "Written to $full_name - New size=$new_size bytes - diff=$diff_size, qual=$quality ...$meol";
   echo "<br>$meol";

   if ($addfullsz || $addoriginal) {
   print "<table><tr>$meol";
   if ($addoriginal) {
   print "<td><img src='$in_file'></td>$meol";
   }
   if ($addfullsz) {
   print "<td><img src='$full_name'></td>$meol";
   }
   print "</tr></table>$meol";
   }
   } else {
   echo "WARNING: Write New image to $full_name FAILED!...$meol";
   echo "<br>$meol";
   }
   } else {
   echo "WARNING: FAILED to COPY image ...$emeol";
   echo "<br>$meol";
   }
   imagedestroy( $new_jpeg );
   }

   $total_size += $file_size; // total in file size = bytes processed
   $total_th += $th_size; // total of thumbs written
   $total_new += $new_size; // total of NEW files created
   if( $diff_size > 0 ) {
   $diff_plus += $diff_size;
   } else {
   $diff_minus += $diff_size;
   }
}

function in_array_nocase($search, &$array) {
 $search = strtolower($search);
 foreach ($array as $item)
 if (strtolower($item) == $search)
 return TRUE;
 return FALSE;
} 

function in_exclude( $dir )
{
   global $excl_dir; // $excl_dir = array('_vti_cnf',...);
   if( in_array($dir, $excl_dir) ) {
   return 1;
   }
   return (in_array_nocase( $dir, $excl_dir ) ? 1 : 0);
}

function ProcessDir($theDir)
{
   global $meol;
   global $do_nm_chg, $IN_NM, $CHG_NM;
   global $path_out, $file_count;
   global $dir_arr, $recursive;
   $mydir = opendir($theDir) ;
   if( !$mydir ) {
   echo "ERROR: Can not OPEN directory [$theDir] ... aborting ... $meol" ;
   exit(3) ;
   }

   // while($fn = readdir($mydir)) //scan through the whole directory
   while(false !== ($fn = readdir($mydir))) //scan through the whole directory
   {
   if( !(($fn == '.') || ($fn == '..')) ) {
   $inp_file = $theDir . '/' . $fn;
   if( is_dir( $inp_file ) ) {
   if ( $recursive ) {
   if( in_exclude( $fn ) ) {
   $skipped[] = $inp_file;
   } else { // if( ! in_exclude( $fn ) ) {
   $dir_arr[] = $inp_file;
   ProcessDir($inp_file);
   }
   }
   } else if( IsJPEGFile( $inp_file ) ) {
   $out_file = strtolower($fn);   // TO LOWER CASE
   if ($do_nm_chg) {   //Perl = if ($fn =~ $IN_NM) - in PHP
   if ( preg_match( $IN_NM, $out_file ) ) {   //Perl = $out_file =~ $IN_NM.$CHG_NM.'/o';
   $out_file = preg_replace( $IN_NM, $CHG_NM, $out_file );
   }
   }
   $file_count++;   // count a file actions
   echo "File $file_count$meol";
   echo "<br>$meol";

   echo "From in name $fn, got out name $out_file ...$meol";
   echo "<br>$meol";

   ProcessFile($inp_file, $path_out, $out_file, $fn);
   }
   }
   }

   closedir($mydir);
}

// unused function
//function LoadJpeg($imgname) 
//{
// $im = @imagecreatefromjpeg($imgname); /* Attempt to open */
// if (!$im) { /* See if it failed */
// $im = imagecreatetruecolor(150, 30); /* Create a black image */
// $bgc = imagecolorallocate($im, 255, 255, 255);
// $tc = imagecolorallocate($im, 0, 0, 0);
// imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
// /* Output an errmsg */
// imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
// }
// return $im;
//}

// unused - output directly to BROWSER
// note: this does NOT appear to work in a local
// command line use ...
//function OutIData($newimage) {
//ob_start(); // start a new output buffer
// imagejpeg( $newimage, "", 75 );
// $ImageData = ob_get_contents();
// $ImageDataLength = ob_get_length();
//ob_end_clean(); // stop this output buffer
//header("Content-type: image/jpeg") ;
//header("Content-Length: ".$ImageDataLength);
//echo $ImageData;
// }
function IsJPEGFile( $in_file ) {
   if ( strtolower( substr($in_file,-4,4) ) == '.jpg' ) {
   return 1;;
   } else if ( strtolower( substr($in_file,-5,5) ) == '.jpeg' ) {
   return 1;
   }
   return 0;
}

function IsJPEGFile2( $in_file ) {
   global $meol;
   if ( !file_exists( $in_file ) ) {
   // echo "ERROR: Can NOT locate file '$in_file' ... aborting ...$meol";
   return 0;
   }
   $file_size = filesize( $in_file );
   // separate path and filename
   $parts = split("/", $in_file);
   $pc = count($parts);
   if( $pc > 1 ) {
   $file_name = $parts[$pc-1]; // last part is FILE NAME
   $patha = array_slice($parts,0,$pc-1); // get array of parts, excluding last ...
   $file_path = implode( "/", $patha);
   } else {
   $file_name = $parts[$pc-1]; // get FILE NAME
   $file_path = ".";
   }
   // echo "Got path of '$file_path', and file name of '$file_name' ...size = $file_size bytes$meol";
   // echo "<br>$meol";

   // separate file name and extention
   $parts = split("\.", $file_name);
   $pc = count($parts);
   if( $pc > 1 ) {
   $file_ext = $parts[$pc-1]; // last part is FILE NAME
   $filea = array_slice($parts,0,$pc-1);
   $file_tit = implode( ".", $filea );
   } else {
   $file_tit = $file_name;
   $file_ext = "";
   }

   // echo "Got file title '$file_tit', extension '$file_ext' ... $meol";
   // echo "<br>$meol";

   if (strtolower( $file_ext ) != 'jpg') {
   // echo "ERROR: NOT a JPG file ... aborting ...$meol";
   // echo "<br>$meol";
   return 0;
   }
   return 1;
}

function getmicrotime() {
 $temparray=split(" ",microtime());
 $returntime=$temparray[0]+$temparray[1];
 return $returntime;
} 

/* Experimenting with the QUALITY setting
 ======================================

With $quality = 75;
Processed 89 jpg files, total 3884136 bytes ...
Processed 46 with thumbs, and 43 without thumbs ...
Total 415628 bytes in thumbs, and total 2020616 bytes in new files ... tot =2436244 bytes
Positive difference = 1619222, and negative difference = -171330 ... sum = 1447892

This represents a substantial GAIN ... there is an overall REDUCTION in disk size of 1.4MB!
But it is clear the new image does NOT look as good ... REJECTED!

With $quality = 80;
Processed 89 jpg files, total 3884136 bytes ...
Processed 46 with thumbs, and 43 without thumbs ...
Total 415628 bytes in thumbs, and total 2125703 bytes in new files ... tot =2541331 bytes
Positive difference = 1514135, and negative difference = -171330 ... sum = 1342805

With $quality = 85;
Processed 89 jpg files, total 3884136 bytes ...
Processed 46 with thumbs, and 43 without thumbs ...
Total 415628 bytes in thumbs, and total 2264905 bytes in new files ... tot =2680533 bytes
Positive difference = 1374933, and negative difference = -171330 ... sum = 1203603

Quality set at 90 ...
Processed 89 jpg files, total 3884136 bytes ...
Processed 46 with thumbs, and 43 without thumbs ...
Total 415628 bytes in thumbs, and total 2519606 bytes in new files ... tot =2935234 bytes
Positive difference = 1120232, and negative difference = -171330 ... sum = 948902

Quality set at 95 ...
Processed 89 jpg files, total 3884136 bytes ...
Processed 46 with thumbs, and 43 without thumbs ...
Total 415628 bytes in thumbs, and total 3127299 bytes in new files ... tot =3542927 bytes
Positive difference = 519948, and negative difference = -178739 ... sum = 341209

This has a MINIMAL GAIN of 340KB of disk space, but even here it is possible
to see a tiny difference in the new image ... BUT it is HARD to tell the DIFFERENCE!
They are essentially the SAME ... if I was going to uploaded PAIRED images,
then this would be the quality level I would choose ...

Quality set at 100 ...
Processed 89 jpg files, total 3884136 bytes ...
Processed 46 with thumbs, and 43 without thumbs ...
Total 415628 bytes in thumbs, and total 4631281 bytes in new files ... tot =5046909 bytes
Positive difference = 0, and negative difference = -1162773 ... sum = -1162773

This represents a LOSS of disk space ... each of the 'new' files is LARGER,
thus a loss of 1.1MB of disk space, and even at this 100% quality level,
the new jpeg still has very slightly LESS clarity ... almost
imperceptable though ...

Decision: Especially since I have already uploaded ALL the images to the site,
then I will ONLY add the thumbnails to the site, and leave each of the original
images in place ... the choice for FUTURE images is still in the balance ...
The Quality of 95 seems about the BEST ...

*/


?>

<hr class="mini">

<p class="top"><a href="#top">top</a>
</p>

<p><a name="end"
 id="end"></a><a target="_blank"
 href="http://tidy.sourceforge.net/"><img border="0"
 src="checked_by_tidy.gif"
 alt="checked by tidy"
 width="32"
 height="32"></a>  <a href="http://validator.w3.org/check?uri=referer"
 target="_blank"><img src="valid-html401.gif"
 alt="Valid HTML 4.01 Transitional"
 width="88"
 height="31"></a></p>
<!-- 2007.06.24 - initial page -->
</body>
</html>

index

Valid HTML 4.01 Transitional