Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. $result = move_uploaded_file($tmpName, $filePath);
  2. $orig_image = imagecreatefromjpeg($filePath);
  3. $image_info = getimagesize($filePath);
  4. $width_orig  = $image_info[0]; // current width as found in image file
  5. $height_orig = $image_info[1]; // current height as found in image file
  6. $width = 1024; // new image width
  7. $height = 768; // new image height
  8. $destination_image = imagecreatetruecolor($width, $height);
  9. imagecopyresampled($destination_image, $orig_image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
  10. // This will just copy the new image over the original at the same filePath.
  11. imagejpeg($destination_image, $filePath, 100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement