Guest User

Untitled

a guest
Dec 14th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. private function minimilize($savefile){
  2.  
  3. $image=new Gmagick($savefile);
  4.  
  5. $width=$image->getimagewidth();
  6. $height=$image->getimageheight();
  7.  
  8. $standartWidth='';
  9. $standartHeight='';
  10. $x='';
  11. $y='';
  12.  
  13. if($width>$height) {
  14.  
  15. $standartWidth=1024;
  16. $standartHeight=756;
  17.  
  18. $masWidth=1300;
  19. $masHeight=900;
  20.  
  21.  
  22. $kw=$width/$masWidth;
  23.  
  24. $wx=$width/$kw;
  25.  
  26. $image->setCompressionQuality(80);
  27. $image->profileimage('*',null);
  28. $image->resizeimage($wx, $wx, null, 1, true);
  29.  
  30.  
  31. $x = (($masWidth - $standartWidth) / 2);
  32. $y = (($masHeight - $standartHeight) / 2);
  33. }
  34.  
  35. if($width<$height) {
  36.  
  37. $standartWidth=1024;
  38. $standartHeight=756;
  39.  
  40. $koef=$width/1024;
  41. $wx=$height/$koef;
  42.  
  43. $image->setCompressionQuality(80);
  44. $image->profileimage('*',null);
  45. $image->resizeimage($wx, $wx, null, 1, true);
  46.  
  47. $x = 0;
  48. $y = $wx/7.75;
  49.  
  50. }
  51.  
  52. $image->cropimage($standartWidth, $standartHeight, $x,$y);
  53. $image->writeimage($savefile);
  54. $image->destroy();
Add Comment
Please, Sign In to add comment