Skip to content

Instantly share code, notes, and snippets.

@oriolrivera
Created November 16, 2013 22:21
Show Gist options
  • Save oriolrivera/7506123 to your computer and use it in GitHub Desktop.
Save oriolrivera/7506123 to your computer and use it in GitHub Desktop.
Escalando imagen con php
<?php
$ruta_imagen = 'images/3rd.jpg';
$escala = 0.20;
$info_fuente = getimagesize($ruta_imagen);
$recurso_fuente = imagecreatefromjpeg($ruta_imagen);
$ancho_nuevo = round($info_fuente[0] * $escala);
$alto_nuevo = round($info_fuente[1] * $escala);
$tipo_mime = $info_fuente['mime'];
$recurso_copia = imagecreatetruecolor($ancho_nuevo, $alto_nuevo);
imagecopyresampled($recurso_copia, $recurso_fuente, 0, 0, 0, 0,
$ancho_nuevo, $alto_nuevo,
$info_fuente[0], $info_fuente[1]);
imagejpeg($recurso_copia, 'images/nuevo.jpg', 100);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment