Skip to content

Commit

Permalink
Revert "[mms] Automatically try to rotate embedded inline images when…
Browse files Browse the repository at this point in the history
… displaying a message."

This reverts commit b7157c3.
  • Loading branch information
slusarz committed Jan 8, 2015
1 parent ea21d7d commit f44fa15
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 92 deletions.
3 changes: 0 additions & 3 deletions imp/config/mime_drivers.php
Expand Up @@ -81,9 +81,6 @@
/* Display images inline that are less than this size (in bytes). */
'inlinesize' => 262144,

/* Auto-rotate inline images? */
'rotate_inline' => true,

/* Display image thumbnails? */
'thumbnails' => true,

Expand Down
2 changes: 0 additions & 2 deletions imp/docs/CHANGES
Expand Up @@ -2,8 +2,6 @@
v7.0.0-git
----------

[mms] Automatically try to rotate embedded inline images when displaying a
message.
[mms] Add ability to add email groups to the address book.
[mms] Improved contacts loading - all contacts are never shown by default, but
provide simple method for user to load all contacts.
Expand Down
4 changes: 0 additions & 4 deletions imp/docs/UPGRADING
Expand Up @@ -76,10 +76,6 @@ MIME Viewer Options (mime_drivers.php)
The ZIP driver now does not show the contents of the ZIP file by default. Set
the 'show_contents' option to true to restore the old behavior.

The Images driver will now automatically try to rotate JPEG images when
displayed inline. Set the 'rotate_inline' option to false to restore the old
behavior (display as-is).

Added the TGZ (tar/gzip) driver.


Expand Down
85 changes: 4 additions & 81 deletions imp/lib/Mime/Viewer/Images.php
Expand Up @@ -58,16 +58,11 @@ public function canRender($mode)
* Return the full rendered version of the Horde_Mime_Part object.
*
* URL parameters used by this function:
* <pre>
* - imp_img_view: (string) One of the following:
* - data: Output the image directly.
* - data_rotate_90: Output the image after rotating 90 degrees.
* - data_rotate_180: Output the image after rotating 180 degrees.
* - data_rotate_270: Output the image after rotating 180 degrees.
* - view_convert: Convert the image to browser-viewable format and
* display.
* - view_thumbnail: Create thumbnail and display.
* </pre>
*
* @return array See parent::render().
*/
Expand All @@ -79,15 +74,6 @@ protected function _render()
* any further delay and exit. */
return parent::_render();

case 'data_rotate_90':
return $this->_viewRotate(90);

case 'data_rotate_180':
return $this->_viewRotate(180);

case 'data_rotate_270':
return $this->_viewRotate(270);

case 'view_convert':
/* Convert image to browser-viewable format and display. */
return $this->_viewConvert(false);
Expand All @@ -110,16 +96,12 @@ protected function _render()
*/
protected function _renderInline()
{
global $browser, $injector;

$type = $this->_getType();

/* Only display the image inline if the browser can display it and the
* size of the image is below the config value. */
if ($browser->isViewable($type)) {
if ($GLOBALS['browser']->isViewable($this->_getType())) {
if (!isset($this->_conf['inlinesize']) ||
($this->_mimepart->getBytes() < $this->_conf['inlinesize'])) {
$showimg = $injector->getInstance('IMP_Images')->showInlineImage($this->getConfigParam('imp_contents'));
$showimg = $GLOBALS['injector']->getInstance('IMP_Images')->showInlineImage($this->getConfigParam('imp_contents'));
} else {
$showimg = false;
}
Expand All @@ -128,36 +110,11 @@ protected function _renderInline()
return $this->_renderInfo();
}

$img_type = 'data';

if ($type == 'image/jpeg') {
$exif = new Horde_Image_Exif_Bundled();
$exif_data = $exif->getData($this->_mimepart->getContents(array(
'stream' => true
)));

if (isset($exif_data['Orientation'])) {
switch (intval($exif_data['Orientation'])) {
case 3:
$img_type = 'data_rotate_180' . $orientation;
break;

case 6:
$img_type = 'data_rotate_90' . $orientation;
break;

case 8:
$img_type = 'data_rotate_270' . $orientation;
break;
}
}
}

/* Viewing inline, and the browser can handle the image type
* directly. So output an <img> tag to load the image. */
return array(
$this->_mimepart->getMimeId() => array(
'data' => $this->_outputImgTag($img_type, $this->_mimepart->getName(true)),
'data' => $this->_outputImgTag('data', $this->_mimepart->getName(true)),
'type' => 'text/html; charset=' . $this->getConfigParam('charset')
)
);
Expand All @@ -173,7 +130,7 @@ protected function _renderInline()
/* See if we can convert to an inline browser viewable form. */
$img = $this->_getHordeImageOb(false);
if ($img &&
$browser->isViewable($img->getContentType())) {
$GLOBALS['browser']->isViewable($img->getContentType())) {
$status->addText(
$this->getConfigParam('imp_contents')->linkViewJS(
$this->_mimepart,
Expand Down Expand Up @@ -274,40 +231,6 @@ protected function _viewConvert($thumb)
);
}

/**
* Rotate image.
*
* @param integer $degrees The number of degrees to rotate.
*
* @return string The image data.
*/
protected function _viewRotate($degrees)
{
global $injector;

/* No need to do image load check previously ... if we can't rotate we
* silently output as-is. */
try {
$img = $injector->getInstance('Horde_Core_Factory_Image')->create();
if ($img->hasCapability('rotate')) {
$type = $this->_mimepart->getType();

$img->setType($type);
$img->loadString($this->_mimepart->getContents());
$img->rotate($degrees);

return array(
$this->_mimepart->getMimeId() => array(
'data' => $img->raw(),
'type' => $type
)
);
}
} catch (Horde_Exception $e) {}

return parent::_render();
}

/**
* Return a Horde_Image object.
*
Expand Down
3 changes: 1 addition & 2 deletions imp/package.xml
Expand Up @@ -33,7 +33,6 @@
</stability>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mms] Automatically try to rotate embedded inline images when displaying a message.
* [mms] Add ability to add email groups to the address book.
* [mms] Improved contacts loading - all contacts are never shown by default, but provide simple method for user to load all contacts.
* [mms] Add dynamically updating relative time display for messages in dynamic view.
Expand Down Expand Up @@ -1279,7 +1278,7 @@
<package>
<name>Horde_Image</name>
<channel>pear.horde.org</channel>
<min>2.2.0</min>
<min>2.0.0</min>
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
Expand Down

0 comments on commit f44fa15

Please sign in to comment.