Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. function redimensionar($pathorigen,$pathdestino) {
  2. list($ancho_or, $alto_or) = getimagesize($pathorigen);
  3.  
  4. $ancho1 = 100 * $ancho_or;
  5. $ancho = $ancho1 / $alto_or;
  6.  
  7. $alto = 100;
  8.  
  9. $thumb = imagecreatetruecolor($ancho, $alto);
  10. $fondo = imagecolorallocate($thumb, 255, 255, 255);
  11. imagefilledrectangle($thumb, 0, 0, $alto_or, $ancho_or, $fondo);
  12.  
  13. $extension = substr($pathorigen,-3);
  14.  
  15. if ($extension == "jpg" || $extension == "peg") {
  16. $origen = imagecreatefromjpeg($pathorigen);
  17.  
  18. imagecopyresampled($thumb, $origen, 0, 0, 0, 0, $ancho, $alto, $ancho_or, $alto_or);
  19. imagejpeg($thumb,$pathdestino,72);
  20. }
  21. else if ($extension == "png") {
  22. $origen = imagecreatefrompng($pathorigen);
  23.  
  24. imagecopyresampled($thumb, $origen, 0, 0, 0, 0, $ancho, $alto, $ancho_or, $alto_or);
  25. imagepng($thumb,$pathdestino,6);
  26. }
  27. else if ($extension == "gif") {
  28. $origen = imagecreatefromgif($pathorigen);
  29.  
  30. imagecopyresampled($thumb, $origen, 0, 0, 0, 0, $ancho, $alto, $ancho_or, $alto_or);
  31. imagegif($thumb,$pathdestino);
  32. }
  33. imagedestroy($thumb);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement