lol - yeah you could say that!
I've been busily working on a thumbnail creator to speed up loading of the page. The original images just filter through in the background for large previews.
My initial script seems to be working very nicely , but it appears some sites won't let me "pinch" the image values so I can wok on them. This I have expected and planned to put an image saying "no thumbnail available", but these are just turning out black....?
+ is there a better way to ensure I get all the thumbs?
code below for reference..
PHP Code:
<?php
require_once('Connections/freewebhost.php');//connection parameters
mysql_select_db($database_freewebhost, $freewebhost);//select mysql database
$query_images = "SELECT * FROM IMAGES WHERE IMAGETHUMB IS NULL AND SIZECHECK > 0 AND SUIT > 0 ORDER BY ID DESC LIMIT 0,10";
$result_images = mysql_query($query_images, $freewebhost) or die(mysql_error());
$row_images = mysql_fetch_assoc($result_images);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<META HTTP-EQUIV=Refresh CONTENT="1">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thumb Creator</title>
</head>
<body>
<p><a href='admin.php'>Admin</a></p>
<?php
do{
$image_url = $row_images['IMAGEURL'];
$image_id = $row_images['ID'];
$time = time();
$info = pathinfo($image_url);
$extension = $info['extension'];
//----------------------------------------------------------------------------
//set max size for thumb
$max_width=110;
$max_height=80;
//header('Content-type: image/jpeg');
// Setting the resize parameters
list($width, $height) = getimagesize($image_url);
if($width>$height){
$modwidth = $max_width;
$factor = $width/$height;
$modheight = $max_width / $factor;
} else {
$modheight = $max_height;
$factor = $height/$width;
$modwidth = $max_height / $factor;
}
// Resizing the Image
$tn = imagecreatetruecolor($modwidth, $modheight);
if($extension =="jpg"){
$image = @imagecreatefromjpeg($image_url);
} elseif ($extension =="png"){
$image = @imagecreatefrompng($image_url);
} elseif ($extension =="gif"){
$image = @imagecreatefromgif($image_url);
}
if (!$image) { /* See if it failed */
$font = 2;
$width = imagefontwidth($font) * strlen($string);
$height = imagefontheight($font);
$image = imagecreatetruecolor (120,80);
$white = imagecolorallocate ($image,255,255,255);
$black = imagecolorallocate ($image,0,0,0);
imagefill($image,0,0,$white);
imagestring ($image,$font,0,0,"No thumb available",$black);
} else {
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
$new_filename = $image_id.".jpg";
$save = 'thumbs/'.$new_filename;
imagejpeg($tn, $save, 100);
}
imagedestroy($tn);
imagedestroy($image);
//----------------------------------------------------------------------------
$updateSQL1 = "UPDATE IMAGES SET IMAGETHUMB='$new_filename' WHERE ID='$image_id'";
$Result2 = mysql_query($updateSQL1, $freewebhost) or die(mysql_error());
echo "<hr/>";
echo "Image thumb for ".$image_url." created at :".date("d/m/Y H:i:s", $time);
echo "<hr/>";
} while ($row_images = mysql_fetch_assoc($result_images));
?>
</body>
</html>
<?php
mysql_free_result($result_images);
?>