Prehral jsem svy stranky na WEBZDARMA a prestali se zobrazovat nahledy fotek vygenerovany GD2 knihovnou. ( adrenalinworld.wz.cz/index.php )
Normalni fotky jsou v O.K. Predtim jsem to mel na linuxovym servru, PHP 4.1.2 a vse chodilo vporadku
kontroloval jsem velikost pismen v nazvech souboru. Vse O.K.
nahledy se generuji prikazem Imagecreatetruecolor()
Vumec me nenapada co s tim. Diky za kazdou radu. Pavel
Vsechno je ulozeny na WEBZDARMA adrenalinworld@wz.cz
jako master zrejme mate pristup ke vsemu
jestli ne tak poslu heslo
jedna se o casti:
templates\default\listing.tpl.php - galleryThumbnailLinked()
templates\default\galery.tpl.php - galleryThumbnailLinked()
includes\singapure.class.php - funkce galleryThumbnailLinked() a galleryThumbmailImage()
thumb.php
vypada to slozite ale da se to tam najit. Nejsem zadnej expert takze spis patram a hledam radu.
Diky za jakoukoliv pomoc
Pavel
Bohuzel je toho vic.
fce na vytvoreni obrazku nejsou dlouhy ale je to potreba zkouknout jako celek. Aspon si to myslim. Jeste pripominam ze mi to na jinym servru bezi, ale budu to muset brzo smazat.
Tady je asi jak to funguje:
Stranka s nahledy obrazku - odkaz na funci
echo $sg->imageThumbnailLinked()
File s funkcema:
/
* @uses imageThumbnailImage
* @return string
*/
function galleryThumbnailLinked($index = null)
{
if($index === null) $galleryId = $this->gallery->idEncoded;
else $galleryId = urlencode($this->gallery->galleries[$index]->id);
$ret = "<a href=\"".$this->config->base_url."gallery=".$galleryId."\">";
$ret .= $this->galleryThumbnailImage($index);
$ret .= "</a>";
return $ret;
}
/
* @return string
*/
function galleryThumbnailImage($index = null)
{
if($index === null) $gal = $this->gallery;
else $gal = $this->gallery->galleries[$index];
switch($gal->filename) {
case "__random__" :
if(count($gal->images)>0) {
srand(time());
$index = rand(0,count($gal->images)-1);
$ret = "<img src=\"thumb.php?gallery=".urlencode($gal->id);
$ret .= "&image=".urlencode($gal->images[$index]->filename);
$ret .= "&size=".$this->config->gallery_thumb_size."\" class=\"sgGallery\" ";
$ret .= "alt=\"".$this->_g("Sample image from gallery")."\" />";
break;
}
case "__none__" :
$ret = nl2br($this->_g("No\nthumbnail"));
break;
default :
$ret = "<img src=\"thumb.php?gallery=".urlencode($gal->id);
$ret .= "&image=".urlencode($gal->filename);
$ret .= "&size=".$this->config->gallery_thumb_size."\" class=\"sgGallery\"";
$ret .= "alt=\"".$this->_g("Sample image from gallery")."\" />";
}
return $ret;
}
/
------------------------
thumb.php je - zde se tvori nahledy -neco jsem umazal aby to nebylo tak dlouhy
obrazky se skutecne vytvori a zustavaji v cache adresari
<?php
/
* Creates and caches a thumbnail of the specified size for the
* specified image.
*/
//require config class
require_once "includes/config.class.php";
showThumb($_REQUEST["gallery"],$_REQUEST["image"], $_REQUEST["size"]);
function showThumb($gallery, $image, $maxsize) {
//create config object
$config = new sgConfig();
//check if image is remote (filename starts with 'http://')
$isRemoteFile = substr($image,0,7)=="http://";
if($isRemoteFile) $imagePath = $image;
else $imagePath = $config->pathto_galleries."$gallery/$image";
$thumbPath = $config->pathto_cache.$maxsize.strtr("-$gallery-$image",":/?\\","----");
$imageModified = @filemtime($imagePath);
$thumbModified = @filemtime($thumbPath);
$thumbQuality = $config->thumbnail_quality;
list($imageWidth, $imageHeight, $imageType) = GetImageSize($imagePath);
//send appropriate headers
switch($imageType) {
case 7 :
case 2 :
default: header("Content-type: image/jpeg"); break;
}
//if thumbnail is newer than image then output cached thumbnail and exit
if($imageModified<$thumbModified) {
header("Last-Modified: ".gmdate("D, d M Y H:i:s",$thumbModified)." GMT");
readfile($thumbPath);
exit;
}
//otherwise thumbnail is out of date or doesn't exist so create new one
//compute width and height of thumbnail to create
if($imageWidth < $imageHeight && ($imageWidth>$maxsize || $imageHeight>$maxsize)) {
$thumbWidth = round($imageWidth/$imageHeight * $maxsize);
$thumbHeight = $maxsize;
} elseif($imageWidth>$maxsize || $imageHeight>$maxsize) {
$thumbWidth = $maxsize;
$thumbHeight = round($imageHeight/$imageWidth * $maxsize);
} else {
$thumbWidth = $imageWidth;
$thumbHeight = $imageHeight;
}
//set default files permissions
//umask($config->umask);
//if file is remote then copy locally first
if($isRemoteFile) {
$ip = fopen($imagePath, "rb");
$tp = fopen($thumbPath, "wb");
while(fwrite($tp,fread($ip, 4096)));
fclose($tp);
fclose($ip);
$imagePath = $thumbPath;
}
switch($config->thumbnail_software) {
case "im" : //use ImageMagick
$cmd = $config->pathto_convert;
$cmd .= " -geometry {$thumbWidth}x{$thumbHeight}";
if($imageType == 2) $cmd .= " -quality $thumbQuality";
if($config->remove_jpeg_profile) $cmd .= " +profile \"*\"";
$cmd .= ' "'.escapeshellcmd($imagePath).'" "'.escapeshellcmd($thumbPath).'"';
exec($cmd);
readfile($thumbPath);
break;
case "gd2" :
default : //use GD by default
//read in image as appropriate type
switch($imageType) {
case 2 :
default: $image = ImageCreateFromJPEG($imagePath); break;
}
switch($config->thumbnail_software) {
case "gd2" :
//create blank truecolor image
$thumb = ImageCreateTrueColor($thumbWidth,$thumbHeight);
//resize image with resampling
ImageCopyResampled($thumb,$image,0,0,0,0,$thumbWidth,$thumbHeight,$imageWidth,$imageHeight);
break;
}
//output image of appropriate type
switch($imageType) {
case 2 :
default:
ImageJPEG($thumb,"",$thumbQuality);
ImageJPEG($thumb,$thumbPath,$thumbQuality);
break;
}
ImageDestroy($image);
ImageDestroy($thumb);
}
}
?>
Omlouvam se ze je to tak dlouhy. Predem diky za pomoc.
Pavel