Autor Zpráva
TomAsQo
Profil
ahoj,
nepoznate nejaky thumbnail generator priamo v PHP, ktory mi z velkeho obrazka spravi maly?
robim totiz stranku s veeela obrazkami a potrebujem z nich pri kazdej stranke vygenerovat malicky nahlad...
any ideas? diky:)
obin
Profil *
if (!(file_exists($adr."/nahledy/".$file)) ) {
$dest = ImageCreateFromJpeg($adr."/".$file);
$image = ImageCreateTrueColor($tb_w,$tb_h);
ImageCopyResampled($image,$dest,0,0,0,0,$tb_w,$tb_h,$width,$height);
ImageJpeg($image,$adr."/nahledy/".$file);
ImageJpeg($image, null, 0);

}
TomAsQo
Profil
huha, tomu ImageCopyResampled ani po manuale nerozumiem velmi ;( ako spravim z lubovolneho obrazka nahlad 70 x 70 pixlov?
prepacte, ze chcem rovno hotscript miesto studovania manualu, ale nemam velmi cas ;(
TomAsQo
Profil
ahoj,
modifijkoval som kusa nasledujuci kod, ale akosi to stale nefunguje ;( kde je chyba?
<?php
/*
ImageThumb - Vytvori zmensenu fotografiu z povodnej
SourceImage - Poloha (adresar) povodnej z ktoreho chcete vytvorit zmensenu fotografiu 
DestImage - Poloha (adresar) kde chcete ulozit zmensenu fotografiu
Width - Pozadovana zmensena sirka fotografie
Height - Pozadovana zmensena vyska fotografie
Type - Typ fotografie v akom chcete zmensenu fotografiu ulozit (jpg,gif...)

*/ 


function ImageThumb($sourceImage = "../adresar/velkefotky", $destImage = "../adresar/malefotky", $width = "70px", $height = "70px", $type = "jpeg") {
$type = strtolower($type);
$imageSize = getimagesize($sourceImage);

if($imageSize[0] > $imageSize[1]) {
$newWidth = $width;
$newHeight = $imageSize[1] * ($newWidth / $imageSize[0]);
}
else {
$newHeight = $height;
$newWidth = $imageSize[0] * ($newHeight / $imageSize[1]);
}

switch(image_type_to_mime_type($imageSize[2])) {
case "image/jpeg":
$image = imagecreatefromjpeg($sourceImage);
break;
case "image/gif":
$image = imagecreatefromgif($sourceImage);
break;
case "image/png":
$image = imagecreatefrompng($sourceImage);
break;
default:
$t = image_type_to_mime_type($imageSize[2]);
echo "The file type {$t} is not supported, please use either jpeg, gif, or png";
break;
}

$thumb = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($thumb, $image, 0, 0, 0, 0, $newWidth, $newHeight, $imageSize[0], $imageSize[1]);
/*
switch($type) {
case "jpg":
case "jpeg":
header("Content-type: image/jpeg");
imagejpeg($thumb, $destImage);
break;
case "gif":
header("Content-type: image/gif");
imagegif($thumb, $destImage);
break;
case "png":
header("Content-type: image/png");
imagepng($thumb, $destImage);
break;
default:
"The image type {$type} is not supported, please choose another.";
break;
}
*/
}

ImageThumb("./gallery/mixmaxdietfeeder_1.jpg","./gallery/aaaa_mixmaxdietfeeder_1_thumb.jpg");
?>



<?
$file = "vaccumtanker_1.jpg";
$tb_w = "70px";
$tb_h = "70px";

//if (!(file_exists($adr."/nahledy/".$file)) ) { 
	$dest = ImageCreateFromJpeg("./gallery/".$file); 
	$image = ImageCreateTrueColor($tb_w,$tb_h); 
	ImageCopyResampled($image,$dest,0,0,0,0,$tb_w,$tb_h,$width,$height); 
	ImageJpeg($image,"./gallery/thumb_".$file); 
	//ImageJpeg($image, null, 0); // nakomentovane, lebo asi odosielalo zly mimetype ci co, lebo zobrazovalo blbosti. a okrem toho mne to staci len ulozit ;)

//}

?>
TomAsQo
Profil
len dodam ten druhy napisany mi vytvori CIERNY stvorec ;(
TomAsQo
Profil
ahoj,
ospravedlnujem sa velmi za lenivost ;(
nakoniec som na to cele prisiel sam, takze dodatocne posielam riesenie pre toho, kto by pouzival vyhladavanie a mal rovnaky problem ako ja:)

// $file_in a $file_out =>cesta k vstupnemu a vystupnemu suboru(napr. "in.jpg" a "out.jpg")
// $tb_w a $tb_h=> roznery, na ake to skonvertovat
function create_thumb($file_in,$file_out,$tb_w="70px", $tb_h="70px"){

	list($width, $height) = getimagesize($file_in);
	$dest = ImageCreateFromJpeg($file_in); 
	$image = ImageCreateTrueColor($tb_w,$tb_h); 
	ImageCopyResampled($image,$dest,0,0,0,0,$tb_w,$tb_h,$width,$height); 
	ImageJpeg($image,$file_out); 

}

este raz sa ospravedlnumem za lenivost, ale mal som velmi malo casu a musl som robit ostatne veci a dakujem obinovi ;)
Toto téma je uzamčeno. Odpověď nelze zaslat.

0