daily pastebin goal
49%
SHARE
TWEET

Untitled

a guest Feb 20th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Set the path to the image to resize
  3. $input_image = "aaa.jpg";
  4. // Get the size of the original image into an array
  5. $size = getimagesize( $input_image );
  6. // Set the new width of the image
  7. $thumb_width = "100";
  8. // Calculate the height of the new image to keep the aspect ratio
  9. $thumb_height = ( int )(( $thumb_width/$size[0] )*$size[1] );
  10. // Create a new true color image in the memory
  11. $thumbnail = ImageCreateTrueColor( $thumb_width, $thumb_height );
  12. // Create a new image from file
  13. $src_img = ImageCreateFromJPEG( $input_image );
  14. // Create the resized image
  15. ImageCopyResampled( $thumbnail, $src_img, 0, 0, 0, 0, $thumb_width, $thumb_height, $size[0], $size[1] );
  16. // Save the image as resized.jpg
  17. ImageJPEG( $thumbnail, "resized.jpg" );
  18. // Clear the memory of the tempory image
  19. ImageDestroy( $thumbnail );
  20. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top