Forum » Programiranje » [PHP] izris slike v različnih formatih
[PHP] izris slike v različnih formatih
matijaz74 ::
<?php // The file //$filename = 'img/spring.jpg'; if(isset($_GET["f"])) $filename=$_GET["f"]; else $filename = 'img/spring.jpg'; if(!isset($_GET["w"])){ if(isset($_GET["per"])) $percent = $_GET["per"]; else $percent = 0.75; } // Content type $mime = image_type_to_mime_type (exif_imagetype ($filename)); header('Content-Type: '.$mime); // Get new dimensions list($width, $height) = getimagesize($filename); if(isset($_GET["w"])){ $new_width = $_GET["w"]; $percent = $new_width/$width; }else{ $new_width = $width * $percent; } $new_height = $height * $percent; // Resample $image_p = imagecreatetruecolor($new_width, $new_height); if($mime="image/jpg") $image = imagecreatefromjpeg($filename); elseif($mime="image/png") $image = imagecreatefrompng($filename); elseif($mime="image/gif") $image = imagecreatefromgif($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // Output if($mime="image/jpeg") imagejpeg($image_p, null, 100); elseif($mime="image/png") imagepng($image_p, null, 100); elseif($mime="image/gif") imagegif($image_p, null, 100); imagedestroy($image_p); ?>
Problem imam pri izrisu različnih formatov. PNG in GIF mi noče izrisati. Kje sem naredil napako. Hvala!
V prvi datoteki kličem ...
<div style="background-image:url('v2.php?w=250<?php echo '&f='.$filename; ?>'); background-color:#FFFFFF; background-position:center; background-repeat:no-repeat; width:500px; height:500px; box-shadow:1px 1px 6px #666666; border:#FFFFFF 0px solid; border-radius:6px;"></div>
lp
Matijaž
Matijaž
- spremenil: matijaz74 ()
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | SIM800L modul in Arduino NanoOddelek: Elektrotehnika in elektronika | 2923 (1736) | domenc |
» | Bash osnoveOddelek: Programiranje | 2024 (814) | Brane22 |
» | problem pri sprembi root gesla v MySQL v UbuntuOddelek: Pomoč in nasveti | 1279 (859) | killa bee |
» | naslednji dve nalogi iz Matematike 2Oddelek: Šola | 2190 (1740) | lebdim |
» | [UBUNTU 10.04] GRUB se ne postaviOddelek: Operacijski sistemi | 5883 (5667) | matijaz74 |