Guest User

Untitled

a guest
Jan 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. $targ_w = $targ_h = 150;
  2. $jpeg_quality = 90;
  3.  
  4. $src = $_POST['n'];
  5. $img_r = imagecreatefromjpeg($src);
  6. $dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
  7.  
  8. $new_src = str_replace('/temp','',$_POST['n']);
  9.  
  10. imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
  11. $targ_w,$targ_h,$_POST['w'],$_POST['h']);
  12.  
  13. imagejpeg($dst_r,$new_src,$jpeg_quality);
  14.  
  15. $targ_w = $targ_h = 150;
  16. $newImage = imagecreatetruecolor($targ_w, $targ_h);
  17. imagealphablending($newImage, false);
  18. imagesavealpha($newImage, true);
  19. $transparent = imagecolorallocatealpha($newImage, 255, 255, 255, 127);
  20. imagefilledrectangle($newImage, 0, 0, $targ_w, $targ_h, $transparent);
  21.  
  22. $src = $_POST['n'];
  23. $img_r = imagecreatefromstring(file_get_contents($src));
  24. $img_r_size = getimagesize($src);
  25.  
  26. $width_r = $img_r_size[0];
  27. $height_r = $img_r_size[1];
  28. if($width_r > $height_r){
  29. $width_ratio = $targ_w / $width_r;
  30. $new_width = $targ_w;
  31. $new_height = $height_r * $width_ratio;
  32. } else {
  33. $height_ratio = $targ_h / $height_r;
  34. $new_width = $width_r * $height_ratio;
  35. $new_height = $targ_h;
  36. }
  37.  
  38. imagecopyresampled($newImage, $img_r, 0, 0, 0, 0, $new_width, $new_height, $width_r, $height_r);
  39.  
  40. $new_src = str_replace('/temp','',$_POST['n']);
  41. imagepng($newImage, $new_src);
  42.  
  43. imagealphablending($target_image, false);
  44. imagesavealpha($target_image, true);
Add Comment
Please, Sign In to add comment