Re: Thumbnails en PHP

From: Date: Tue, 18 Dec 2001 18:50:41 +0000
Subject: Re: Thumbnails en PHP
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-16849@lists.php.net to get a copy of this message
Yo he usado convert desde exec() para este tipo de cosas. NAME convert - converts an input file using one image format to an output file with the same or differing image format. Es una utilidad de ImageMagick. El Lun 17 Dic 2001 17:09, escribió: > 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; > } > ?>

« previous php.general.es (#16849) next »