• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Is XenForos ImageMagick too late for the original file, can only manipulate thumbnails?

Marcus

Well-known member
#1
This is for: http://xenforo.com/community/resources/auto-image-orientation-for-iphone-and-ipad.1755/

This addon rotates the thumbnail in the right position, however in full view the picture is still not rotated. Is the full image already saved before this class is triggered and am I too late here? If yes, can I still have access to the original image to rotate it right?
PHP:
class AutoRotate_Image_Imagemagick_Pecl extends XFCP_AutoRotate_Image_Imagemagick_Pecl
{
  protected function _setImage(Imagick $image)
  {
  $orientation = $image->getImageOrientation();

  switch($orientation) {
  case Imagick::ORIENTATION_BOTTOMRIGHT:
  $image->rotateimage(new ImagickPixel(), 180);
  break;

  case Imagick::ORIENTATION_RIGHTTOP:
  $image->rotateimage(new ImagickPixel(), 90);
  break;

  case Imagick::ORIENTATION_LEFTBOTTOM:
  $image->rotateimage(new ImagickPixel(), -90);
  break;
  }

  $image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);

  return parent::_setImage($image);
  }
}
 

Attachments

Marcus

Well-known member
#2
This class is first executed in XenForo_Upload::_checkImageState()

XenForo_Model_Attachment::insertUploadedAttachmentData() writes to XenForo_DataWriter_AttachmentData

Is it more convenient to extend XenForo_DataWriter_AttachmentData::_preSave()?