Posted By

catchamonkey on 09/09/08


Tagged

plugin imagemagick symfony sfThumbnail


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

catchamonkey


ImageMagick sfThumbnail Plugin fix under symfony


 / Published in: PHP
 

The plugin's "shave_all" function was not properly cropping and resizing the thumbnails for me. The following needs to be changed in sfImageMagickAdapter.class.php

  1. Change lines 223-237:
  2.  
  3. $width = $this->sourceWidth;
  4. $height = $this->sourceHeight;
  5. $x = $y = 0;
  6. switch (@$this->options['method']) {
  7. case "shave_all":
  8. if ($width > $height)
  9. {
  10. $x = ceil(($width - $height) / 2 );
  11. $width = $height;
  12. }
  13. elseif ($height > $width)
  14. {
  15. $y = ceil(($height - $width) / 2);
  16. $height = $width;
  17. }
  18.  
  19. to:
  20.  
  21. $width = $this->sourceWidth;
  22. $height = $this->sourceHeight;
  23. $mWidth = $this->maxWidth;
  24. $mHeight = $this->maxHeight;
  25. $x = $y = 0;
  26. switch (@$this->options['method']) {
  27. case "shave_all":
  28. if ($width > $height)
  29. {
  30. $x = ceil(($width - ($height*$mWidth)/$mHeight) / 2 );
  31. $width = $height;
  32. }
  33. elseif ($height > $width)
  34. {
  35. $y = ceil(($height - $width*($mHeight/$mWidth)) / 2);
  36. $height = $width;
  37. }

Report this snippet  

You need to login to post a comment.