@MileG samo koliko znam kod izgleda ovako
Code:
echo "<a href='nesto.php?'><img src='resize.php?slika=putanjadoslike' /></a>";
Evo kako sve skupa glasi!!!
sastoji se od dvije datoteke i može se koristiti za bilo koji tip slike bilo gdje na netu!
1 file je kretak a zove se slike.php
Code:
<?php
$slika = $_GET['ime'];
$tip = $_GET['tip'];
$visina = $_GET['visina'];
echo "<a href='$slika'><img src='mjenjanje.php?ime=$slika&tip=$tip&visina=$visina' /></a>";
?>
drugi se zove mjenjanje.php
Code:
<?php
$slika = $_GET['ime'];
$tip = $_GET['tip'];
$visina = $_GET['visina'];
$picname = resizepics("$slika.$tip", "$visina", "0");
echo $pickname;
//Error
die( "<font color=\"#FF0066\"><center><b>Krivo unešena datoteka :(<b></center></FONT>");
//Funcion resizepics
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);
}
}
?>
da sve radi kako treba otvorite stranicu slika.php, ali na način
Code:
....slika.php?ime=|-ime_slike(bez_jpg,gif,...)-|&tip=|-tu stavite tip gif, jpg,...-|&visina=|-stavite visinu koju želite|
čak mi je radilo ako stavim ove datoteke u jedan direktorij i s njima stavim neku sliku npr. jadibjeda.jpg kad utipkam u address bar ..../datoteka/jadibjeda on otvara tu sliku
možda je to narmalno, ispravite me, ali za mene je to novo!