Re: Thumbnails en PHP
| From: | Xytras | Date: | Sun, 16 Dec 2001 17:26:34 +0000 |
| Subject: | Re: Thumbnails en PHP | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-16795@lists.php.net to get a copy of this message | ||
lo mas logico para eso sera que uses algun editor de imagenes y hagas las
imagenes del tamaño deseado
de hecho existe una aplicacion llamada thumbsplus para win que hace
thumbnails
Xytras
----- Original Message -----
From: <axier_ddk@terra.es>
To: <lista@phpes.com>
Sent: Monday, December 17, 2001 9:09 AM
Subject: [PHP-ES] Thumbnails en PHP
> Aupa!
> Despues de convencerme para no guardar las imagenes en BDs tengo otra
> duda sobre esto.
> La cosa es que quiero que una pagina me haga las miniaturas
> automaticamente para que solo tenga que copiarlas al directorio donde
> las voy a guardar. Segun lo he hecho las cambia de tamaño perfectamente
> pero en todas pierde todo el color, no hay manera de que haga una
> copia exacta(o con algo menos de calidad) sin que pierda el color???
> Utilizo algo asi:
>
> <?
> function thumbnail($path) {
>
> if (is_readable($path)) {
> $hw = GetImageSize($path);
>
> $x = 135;
> $y = 90;
>
> $src = imagecreatefrom($path);
> $new = imagecreate($x, $y);
>
> imagecopyresized($new, $src, 0, 0, 0, 0, $x, $y, $hw[0], $hw[1]);
> imagejpeg($new,$path,80);
> }
> }
>
> function imagecreatefrom($tmpfile) {
> $type = imagetype(join("",file($tmpfile)));
> switch ($type) {
> case "gif":
> $new_img = imagecreatefromgif($tmpfile);
> break;
> case "png":
> $new_img = imagecreatefrompng($tmpfile);
> break;
> case "jpeg":
> default:
> $new_img = imagecreatefromjpeg($tmpfile);
> }
> return $new_img;
> }
>
> function imagetype($data) {
> $sub = substr($data, 0, 20);
> if (preg_match("/GIF/",$sub)) {
> $str = "gif";
> }
> if (preg_match("/JFIF/",$sub)) {
> $str = "jpeg";
> }
> if (preg_match("/Exif/",$sub)) {
> $str = "jpeg";
> }
> if (preg_match("/PNG/", $sub)) {
> $str = "png";
> }
> return $str;
> }
> ?>
>
>
>
> --
> Best regards,
> axier mailto:axier_ddk@terra.es
>
>
>
> ---------------------------------------------------------------------
> Archivo On-line: http://www.phpes.com/
> Manual PHP en español: http://www.php.net/manual/es/
> Para dar de baja la suscripción, mande un mensaje a:
> lista-unsubscribe@phpes.com