Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function redimensionar($pathorigen,$pathdestino) {
- list($ancho_or, $alto_or) = getimagesize($pathorigen);
- $ancho1 = 100 * $ancho_or;
- $ancho = $ancho1 / $alto_or;
- $alto = 100;
- $thumb = imagecreatetruecolor($ancho, $alto);
- $fondo = imagecolorallocate($thumb, 255, 255, 255);
- imagefilledrectangle($thumb, 0, 0, $alto_or, $ancho_or, $fondo);
- $extension = substr($pathorigen,-3);
- if ($extension == "jpg" || $extension == "peg") {
- $origen = imagecreatefromjpeg($pathorigen);
- imagecopyresampled($thumb, $origen, 0, 0, 0, 0, $ancho, $alto, $ancho_or, $alto_or);
- imagejpeg($thumb,$pathdestino,72);
- }
- else if ($extension == "png") {
- $origen = imagecreatefrompng($pathorigen);
- imagecopyresampled($thumb, $origen, 0, 0, 0, 0, $ancho, $alto, $ancho_or, $alto_or);
- imagepng($thumb,$pathdestino,6);
- }
- else if ($extension == "gif") {
- $origen = imagecreatefromgif($pathorigen);
- imagecopyresampled($thumb, $origen, 0, 0, 0, 0, $ancho, $alto, $ancho_or, $alto_or);
- imagegif($thumb,$pathdestino);
- }
- imagedestroy($thumb);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement