evo kako sam ja napravio za sliku, za stranicu se izbaci mjenjanje.php i malo promjeni index.php
evo:
index.php
Code:
<?php
$vrijeme = $_GET['t']; // ne dirat //
echo "<META http-equiv='refresh' content='$vrijeme'>"; //ovde ništa ne mjenjat//
echo "<img src='mjenjanje.php?ime=web&tip=jpg&visina=500'>"; // ovo se mjenja ako se stranica učitava, trebalo i pomoču <iframe..
// ili ovo zadnje 500 se može isto tako preko $_GET, ali nije potrebno ako ovo stavljate u neki okvir
//web i jpg mjenjate, zavisi od slike do slike, u ovom primjeru je bilo web.jpg
?>
mjenjanje.php - samo za slike // ništa ne mjenjat
Code:
<?php
$slika = $_GET['ime'];
$tip = $_GET['tip'];
$visina = $_GET['visina'];
$picname = resizepics("$slika.$tip", "$visina", "0");
function resizepics($pics, $newwidth, $newheight){
if(preg_match("/.jpg/i", "$pics")){
header('Content-type: image/jpeg');
}
if (preg_match("/.gif/i", "$pics")){
header('Content-type: image/gif');
}
list($width, $height) = getimagesize($pics);
if($width > $height && $newheight < $height){
$newheight = $height / ($width / $newwidth);
} else if ($width < $height && $newwidth < $width) {
$newwidth = $width / ($height / $newheight);
} else {
$newwidth = $width;
$newheight = $height;
}
if(preg_match("/.jpg/i", "$pics")){
$source = imagecreatefromjpeg($pics);
}
if(preg_match("/.jpeg/i", "$pics")){
$source = imagecreatefromjpeg($pics);
}
if(preg_match("/.jpeg/i", "$pics")){
$source = Imagecreatefromjpeg($pics);
}
if(preg_match("/.png/i", "$pics")){
$source = imagecreatefrompng($pics);
}
if(preg_match("/.gif/i", "$pics")){
$source = imagecreatefromgif($pics);
}
$thumb = imagecreatetruecolor($newwidth, $newheight);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
return imagejpeg($thumb);
if(preg_match("/.jpg/i", "$pics")){
return imagejpeg($thumb);
}
if(preg_match("/.jpeg/i", "$pics")){
return imagejpeg($thumb);
}
if(preg_match("/.jpeg/i", "$pics")){
return imagejpeg($thumb);
}
if(preg_match("/.png/i", "$pics")){
return imagepng($thumb);
}
if(preg_match("/.gif/i", "$pics")){
return imagegif($thumb);
}
}
?>
[Ovu poruku je menjao Frane Marinković dana 07.01.2006. u 11:59 GMT+1]