Guest User

Untitled

a guest
Jul 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. if ($width < $originalWidth && $height < $originalHeight) {
  2. $aspectRatio = $width / $height;
  3. $aspectRatioIncoming = $originalWidth / $originalHeight;
  4.  
  5. if ($aspectRatioIncoming > 1) {
  6. $heightCrop = $originalWidth / $aspectRatio;
  7. $widthCrop = $heightCrop * $aspectRatio;
  8. } else {
  9. $widthCrop = $originalHeight * $aspectRatio;
  10. $heightCrop = $widthCrop / $aspectRatio;
  11. }
  12.  
  13. $image->crop(floor($widthCrop), floor($heightCrop));
  14.  
  15. $resizeWidth = $this->retinaSize($width);
  16. $resizeHeight = $this->retinaSize($height);
  17.  
  18. $image->resize(floor($resizeWidth), floor($resizeHeight));
  19. }
Add Comment
Please, Sign In to add comment