Advertisement
irokemr

Shop

Nov 5th, 2019
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. $imagefile = $imagen2[0];
  2.  
  3. /**
  4.  * Opens new image
  5.  *
  6.  * @param $filename
  7.  */
  8. function icreate($filename)
  9. {
  10.   $isize = getimagesize($filename);
  11.   if ($isize['mime']=='image/jpeg')
  12.     return imagecreatefromjpeg($filename);
  13.   elseif ($isize['mime']=='image/png')
  14.     return imagecreatefrompng($filename);
  15.   /* Add as many formats as you can */
  16. }
  17.  
  18. /**
  19.  * Simple image resample into new image
  20.  *
  21.  * @param $image Image resource
  22.  * @param $width
  23.  * @param $height
  24.  */
  25. function simpleresize($image, $width, $height)
  26. {
  27.   $new = imageCreateTrueColor($width, $height);
  28.   imagecopyresampled($new, $image, 0, 0, 0, 0, $width, $height, imagesx($image), imagesy($image));
  29.   return $new;
  30. }
  31.  
  32. $imgh = icreate($imagefile);
  33. $imgr = simpleresize($imgh, 512, 512);
  34.  
  35. header('Content-type: image/png');
  36. imagepng($imgr);?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement