I had some trouble with images showing red x'es so I made some fixes to resize.php
change:
Code: Select all
// Check the file exists, if not use the default
if (file_exists($_GET['img']) == FALSE) {
$_GET['img'] = $default_img;
}
to:
Code: Select all
// Check the file exists, if not use the default
if ((file_exists($_GET['img']) == FALSE) || is_dir($_GET['img'])) {
$_GET['img'] = $default_img;
}
helps if there is no picturename in the database for the movie
change:
Code: Select all
// If chaching is ON, check to see we already created this file.
if ($caching == TRUE) {
$cachename = md5(print_r($_GET, TRUE)).".png";
$cachefile = $cachedir.$cachename;
if (file_exists($cachefile)) {
// Output our cached file, that was easy.
header("Content-Type: image/png");
header("Expires: ".gmdate("D, d M Y H:i:s",time()+24*60*60));
imagepng(imagecreatefrompng($cachefile));
exit();
}
}
to:
Code: Select all
// If chaching is ON, check to see we already created this file.
if ($caching == TRUE) {
$cachename = md5(print_r($_GET, TRUE)).".png";
$cachefile = $cachedir.$cachename;
if (file_exists($cachefile)) {
// Output our cached file, that was easy.
header("Content-Type: image/png");
header("Expires: ".gmdate("D, d M Y H:i:s",time()+24*60*60));
if(imagepng(imagecreatefrompng($cachefile))){
exit();
}
}
}
removes some problems if the cached file is corrupt in some way.
And another fix to decrease the loading time of non cached images and increase the quality.
insert after $default_img = "default_cover.jpg"; :
Code: Select all
function fastimagecopyresampled (&$dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h, $quality = 2) {
// Plug-and-Play fastimagecopyresampled function replaces much slower imagecopyresampled.
// Just include this function and change all "imagecopyresampled" references to "fastimagecopyresampled".
// Typically from 30 to 60 times faster when reducing high resolution images down to thumbnail size using the default quality setting.
// Author: Tim Eckel - Date: 09/07/07 - Version: 1.1 - Project: FreeRingers.net - Freely distributable - These comments must remain.
//
// Optional "quality" parameter (defaults is 3). Fractional values are allowed, for example 1.5. Must be greater than zero.
// Between 0 and 1 = Fast, but mosaic results, closer to 0 increases the mosaic effect.
// 1 = Up to 350 times faster. Poor results, looks very similar to imagecopyresized.
// 2 = Up to 95 times faster. Images appear a little sharp, some prefer this over a quality of 3.
// 3 = Up to 60 times faster. Will give high quality smooth results very close to imagecopyresampled, just faster.
// 4 = Up to 25 times faster. Almost identical to imagecopyresampled for most images.
// 5 = No speedup. Just uses imagecopyresampled, no advantage over imagecopyresampled.
if (empty($src_image) || empty($dst_image) || $quality <= 0) { return false; }
if ($quality < 5 && (($dst_w * $quality) < $src_w || ($dst_h * $quality) < $src_h)) {
$temp = imagecreatetruecolor ($dst_w * $quality + 1, $dst_h * $quality + 1);
imagecopyresized ($temp, $src_image, 0, 0, $src_x, $src_y, $dst_w * $quality + 1, $dst_h * $quality + 1, $src_w, $src_h);
imagecopyresampled ($dst_image, $temp, $dst_x, $dst_y, 0, 0, $dst_w, $dst_h, $dst_w * $quality, $dst_h * $quality);
imagedestroy ($temp);
} else imagecopyresampled ($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
return true;
}
and change:
Code: Select all
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $w, $h, $width, $height);
to
Code: Select all
fastimagecopyresampled($image_resized, $image, 0, 0, 0, 0, $w, $h, $width, $height);
but the image is still a little blocky so we change this line in detail_view.tpl and cover_view.tpl
Code: Select all
<img src='$TEMPLATEDIR/images/resize.php?img=$UNIXDIR$COVERSDIR$MOVIE[PICTURENAME]&w=75' alt='$MOVIE[FORMATTEDTITLE]' title='$MOVIE[FORMATTEDTITLE]' />
to
Code: Select all
<img src='$TEMPLATEDIR/images/resize.php?img=$UNIXDIR$COVERSDIR$MOVIE[PICTURENAME]&w=75&h=110' alt='$MOVIE[FORMATTEDTITLE]' title='$MOVIE[FORMATTEDTITLE]' />
to add the height parameter since else the picture would have been stretched to 110px in the browser as set in the css file