Файловый менеджер - Редактировать - C:/xampp/htdocs/cat/files/thumbfill.php
Назад
<?php // Fer un thumb de una imatge centrant i afegint als costats color // REQUIERE POR GET // img -> Ruta completa del JPG // w (ancho) y h (alto) -> de la miniatura resultante. // a (ajuste) -> w por ancho, h por alto // c (color) -> Format web #RRGGBB if ((isset($_GET["img"]))&&(isset($_GET["w"]))&&(isset($_GET["h"]))) { switch(substr($_GET["img"],-4)) { case "jpeg": case ".jpg": $fuente = imagecreatefromjpeg($_GET["img"]); break; case ".gif": $fuente = imagecreatefromgif($_GET["img"]); break; case ".png": $fuente = imagecreatefrompng($_GET["img"]); break; } $imagen = imagecreatetruecolor($_GET["w"],$_GET["h"]); if (isset($_GET["c"])) { $RR = substr($_GET["c"],0,2); $GG = substr($_GET["c"],2,2); $BB = substr($_GET["c"],4,2); $bgcolor = imagecolorallocate($imagen,hexdec($RR),hexdec($GG),hexdec($BB)); } else $bgcolor = imagecolorallocate($imagen, 0, 0, 0); imagefill($imagen,0,0,$bgcolor); if ($_GET["a"] == "h") { $proporcio = imagesx($fuente)/imagesy($fuente); $novaample = $_GET["h"]*$proporcio; $Xdest = ($_GET["w"]-$novaample)/2; imagecopyresampled($imagen,$fuente,(int)$Xdest,0,0,0,(int)$novaample,$_GET["h"],imagesx($fuente),imagesy($fuente)); } if ($_GET["a"] == "w") { $proporcio = imagesy($fuente)/imagesx($fuente); if ($proporcio >1) { $proporcio = imagesx($fuente)/imagesy($fuente); $novaample = $_GET["h"]*$proporcio; $Xdest = ($_GET["w"]-$novaample)/2; imagecopyresampled($imagen,$fuente,(int)$Xdest,0,0,0,(int)$novaample,$_GET["h"],imagesx($fuente),imagesy($fuente)); } else { $novaalto = $_GET["w"]*$proporcio; $Ydest = ($_GET["h"]-$novaalto)/2; imagecopyresampled($imagen,$fuente,0,(int)$Ydest,0,0,$_GET["w"],(int)$novaalto,imagesx($fuente),imagesy($fuente)); } } header("Content-type: image/jpeg"); imagejpeg($imagen); } ?>
| ver. 1.4 |
Github
|
.
| PHP 5.3.8 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка