<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[11899] trunk/wp-includes/media.php:
  Revert rotating images based on EXIF Orientation.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/11899">11899</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2009-09-04 02:36:34 +0000 (Fri, 04 Sep 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Revert rotating images based on EXIF Orientation. Better time for this would be immediately after an image is uploaded, perhaps in media_handle_upload(), see <a href="http://trac.wordpress.org/ticket/7042">#7042</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesmediaphp">trunk/wp-includes/media.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/media.php (11898 => 11899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/media.php        2009-09-02 07:11:07 UTC (rev 11898)
+++ trunk/wp-includes/media.php        2009-09-04 02:36:34 UTC (rev 11899)
</span><span class="lines">@@ -379,31 +379,12 @@
</span><span class="cx">                 if ( !imagegif( $newimage, $destfilename ) )
</span><span class="cx">                         return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
</span><span class="cx">         } elseif ( IMAGETYPE_PNG == $orig_type ) {
</span><del>-                if (!imagepng( $newimage, $destfilename ) )
</del><ins>+                if ( !imagepng( $newimage, $destfilename ) )
</ins><span class="cx">                         return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
</span><span class="cx">         } else {
</span><del>-                $rotated = false;
-                if ( IMAGETYPE_JPEG == $orig_type &amp;&amp; function_exists('exif_read_data') ) {
-                        // rotate if EXIF 'Orientation' is set
-                        $exif = exif_read_data($file, null, true);
-                        if ( $exif &amp;&amp; isset($exif['IFD0']) &amp;&amp; is_array($exif['IFD0']) &amp;&amp; isset($exif['IFD0']['Orientation']) ) {
-                                if ( 6 == $exif['IFD0']['Orientation'] )
-                                        $rotated = rotate_image($newimage, 90);
-                                elseif ( 8 == $exif['IFD0']['Orientation'] )
-                                        $rotated = rotate_image($newimage, 270);
-                        }
-                }
-
</del><span class="cx">                 // all other formats are converted to jpg
</span><span class="cx">                 $destfilename = &quot;{$dir}/{$name}-{$suffix}.jpg&quot;;
</span><del>-                if ( $rotated ) {
-                        $return = imagejpeg( $rotated, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) );
-                        imagedestroy($rotated);
-                } else {
-                        $return = imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) );
-                }
-
-                if ( !$return )
</del><ins>+                if ( !imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) ) ) 
</ins><span class="cx">                         return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -835,101 +816,3 @@
</span><span class="cx"> 
</span><span class="cx">         return array_unique($taxonomies);
</span><span class="cx"> }
</span><del>-
-/**
- * Rotate an image.
- *
- * @since 2.9.0
- *
- * @param resource $src_img GD image handle of source image.
- * @param $angle int clockwise angle of rotation, only 90, 180 and 270 are supported.
- * @param $keep_transparency bool preserve transparency.
- * @return mixed GD image handle of rotated image or false on error.
- */
-function rotate_image( $src_img, $angle, $keep_transparency = false ) {
-
-        if ( function_exists('imagerotate') )
-                return imagerotate($src_img, 360 - $angle, 0); // imagerotate() rotates CCW
-
-        if ( 180 == $angle )
-                return flip_image( $src_img, 'both', $keep_transparency );
-
-        $width = imagesx( $src_img );
-    $height = imagesy( $src_img );
-
-    $dest_img = imagecreatetruecolor( $height, $width );
-    if ( $keep_transparency ) {
-                imagealphablending($dest_img, false);
-                imagesavealpha($dest_img, true);
-        }
-
-        if ( 90 == $angle ) {
-                for( $x = 0; $x &lt; $width; $x++ ) {
-                        for( $y = 0; $y &lt; $height; $y++ ) {
-                                if ( !imagecopy($dest_img, $src_img, $height - $y - 1, $x, $x, $y, 1, 1) )
-                                        return false;
-                        }
-                }
-        } elseif ( 270 == $angle ) {
-                for( $x = 0; $x &lt; $width; $x++ ) {
-                        for( $y = 0; $y &lt; $height; $y++ ) {
-                                if ( !imagecopy($dest_img, $src_img, $y, $width - $x - 1, $x, $y, 1, 1) )
-                                        return false;
-                        }
-                }
-        } else {
-                return false;
-        }
-
-        return $dest_img;
-}
-
-/**
- * Flip an image.
- *
- * @since 2.9.0
- *
- * @param resource $src_img GD image handle of source image.
- * @param $mode string 'horizontal', 'vertical' or 'both'.
- * @param $keep_transparency bool preserve transparency.
- * @return mixed GD image handle of flipped image or false on error.
- */
-function flip_image( $src_img, $mode, $keep_transparency = false ) {
-
-        $width = $src_width = imagesx( $src_img );
-        $height = $src_height = imagesy( $src_img );
-        $src_x = $src_y = 0;
-
-        switch ( $mode ) {
-                case 'vertical':
-                        $src_y = $height -1;
-                        $src_height = -$height;
-                        break;
-                case 'horizontal':
-                        $src_x = $width -1;
-                        $src_width = -$width;
-                        break;
-                case 'both':
-                        if ( function_exists('imagerotate') )
-                                return imagerotate($src_img, 180, 0);
-
-                        $src_x = $width -1;
-                        $src_y = $height -1;
-                        $src_width = -$width;
-                        $src_height = -$height;
-                        break;
-                default:
-                        return false;
-        }
-
-        $dest_img = imagecreatetruecolor( $width, $height );
-        if ( $keep_transparency ) {
-                imagealphablending($dest_img, false);
-                imagesavealpha($dest_img, true);
-        }
-
-        if ( imagecopyresampled( $dest_img, $src_img, 0, 0, $src_x, $src_y , $width, $height, $src_width, $src_height ) )
-                return $dest_img;
-
-        return false;
-}
</del></span></pre>
</div>
</div>

</body>
</html>