Ticket #14459: 14459.2.diff
File 14459.2.diff, 2.1 KB (added by , 7 years ago) |
---|
-
src/wp-includes/class-wp-image-editor-gd.php
116 116 $this->update_size( $size[0], $size[1] ); 117 117 $this->mime_type = $size['mime']; 118 118 119 if ( in_array( $this->mime_type, array( 'image/jpeg', 'image/tiff' ) ) ) { 120 $exif = exif_read_data($this->file); 121 122 $orientation = 0; 123 124 if ( isset($exif["Orientation"]) ) { 125 $orientation = $exif["Orientation"]; 126 } 127 elseif ( isset($exif["IFD0"]) && isset($exif["IFD0"]["Orientation"]) ) { 128 $orientation = $exif["IFD0"]["Orientation"]; 129 } 130 elseif ( isset($exif["COMPUTED"]) && isset($exif["COMPUTED"]["Orientation"]) ) { 131 $orientation = $exif["COMPUTED"]["Orientation"]; 132 } 133 134 switch($orientation) { 135 case 3: 136 $this->rotate(180); 137 break; 138 139 case 6: 140 $this->rotate(-90); 141 break; 142 143 case 8: 144 $this->rotate(90); 145 break; 146 } 147 } 148 119 149 return $this->set_quality(); 120 150 } 121 151 -
src/wp-includes/class-wp-image-editor-imagick.php
154 154 $this->image->setIteratorIndex(0); 155 155 156 156 $this->mime_type = $this->get_mime_type( $this->image->getImageFormat() ); 157 158 if ( is_callable( array( $this->image, 'setImageOrientation' ) ) ) { 159 $orientation = $this->image->getImageOrientation(); 160 161 switch($orientation) { 162 case imagick::ORIENTATION_BOTTOMRIGHT: 163 $this->rotate(180); 164 break; 165 166 case imagick::ORIENTATION_RIGHTTOP: 167 $this->rotate(90); 168 break; 169 170 case imagick::ORIENTATION_LEFTBOTTOM: 171 $this->rotate(-90); 172 break; 173 } 174 175 $this->image->setImageOrientation(imagick::ORIENTATION_UNDEFINED); 176 } 157 177 } 158 178 catch ( Exception $e ) { 159 179 return new WP_Error( 'invalid_image', $e->getMessage(), $this->file );