~canonical-sysadmins/wordpress/4.5.3

« back to all changes in this revision

Viewing changes to wp-includes/class-wp-image-editor-imagick.php

  • Committer: Ryan Finnie
  • Date: 2015-08-31 16:09:47 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: ryan.finnie@canonical.com-20150831160947-1h6rfxby9z1ec62u
Merge WP4.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 */
17
17
class WP_Image_Editor_Imagick extends WP_Image_Editor {
18
18
        /**
 
19
         * Imagick object.
 
20
         *
 
21
         * @access protected
19
22
         * @var Imagick
20
23
         */
21
 
        protected $image; // Imagick Object
 
24
        protected $image;
22
25
 
23
26
        public function __destruct() {
24
27
                if ( $this->image instanceof Imagick ) {
35
38
         * method can be called statically.
36
39
         *
37
40
         * @since 3.5.0
 
41
         *
 
42
         * @static
38
43
         * @access public
39
44
         *
40
 
         * @return boolean
 
45
         * @param array $args
 
46
         * @return bool
41
47
         */
42
48
        public static function test( $args = array() ) {
43
49
 
82
88
         * Checks to see if editor supports the mime-type specified.
83
89
         *
84
90
         * @since 3.5.0
 
91
         *
 
92
         * @static
85
93
         * @access public
86
94
         *
87
95
         * @param string $mime_type
88
 
         * @return boolean
 
96
         * @return bool
89
97
         */
90
98
        public static function supports_mime_type( $mime_type ) {
91
99
                $imagick_extension = strtoupper( self::get_extension( $mime_type ) );
112
120
         * @since 3.5.0
113
121
         * @access protected
114
122
         *
115
 
         * @return boolean|WP_Error True if loaded; WP_Error on failure.
 
123
         * @return true|WP_Error True if loaded; WP_Error on failure.
116
124
         */
117
125
        public function load() {
118
126
                if ( $this->image instanceof Imagick )
128
136
                try {
129
137
                        $this->image = new Imagick( $this->file );
130
138
 
131
 
                        if( ! $this->image->valid() )
 
139
                        if ( ! $this->image->valid() )
132
140
                                return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file);
133
141
 
134
142
                        // Select the first frame to handle animated images properly
156
164
         * @access public
157
165
         *
158
166
         * @param int $quality Compression Quality. Range: [1,100]
159
 
         * @return boolean|WP_Error True if set successfully; WP_Error on failure.
 
167
         * @return true|WP_Error True if set successfully; WP_Error on failure.
160
168
         */
161
169
        public function set_quality( $quality = null ) {
162
170
                $quality_result = parent::set_quality( $quality );
225
233
         *
226
234
         * @param  int|null $max_w Image width.
227
235
         * @param  int|null $max_h Image height.
228
 
         * @param  boolean  $crop
229
 
         * @return boolean|WP_Error
 
236
         * @param  bool     $crop
 
237
         * @return bool|WP_Error
230
238
         */
231
239
        public function resize( $max_w, $max_h, $crop = false ) {
232
240
                if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) )
330
338
         * @since 3.5.0
331
339
         * @access public
332
340
         *
333
 
         * @param int $src_x The start x position to crop from.
334
 
         * @param int $src_y The start y position to crop from.
335
 
         * @param int $src_w The width to crop.
336
 
         * @param int $src_h The height to crop.
337
 
         * @param int $dst_w Optional. The destination width.
338
 
         * @param int $dst_h Optional. The destination height.
339
 
         * @param boolean $src_abs Optional. If the source crop points are absolute.
340
 
         * @return boolean|WP_Error
 
341
         * @param int  $src_x The start x position to crop from.
 
342
         * @param int  $src_y The start y position to crop from.
 
343
         * @param int  $src_w The width to crop.
 
344
         * @param int  $src_h The height to crop.
 
345
         * @param int  $dst_w Optional. The destination width.
 
346
         * @param int  $dst_h Optional. The destination height.
 
347
         * @param bool $src_abs Optional. If the source crop points are absolute.
 
348
         * @return bool|WP_Error
341
349
         */
342
350
        public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
343
351
                if ( $src_abs ) {
374
382
         * @access public
375
383
         *
376
384
         * @param float $angle
377
 
         * @return boolean|WP_Error
 
385
         * @return true|WP_Error
378
386
         */
379
387
        public function rotate( $angle ) {
380
388
                /**
403
411
         * @since 3.5.0
404
412
         * @access public
405
413
         *
406
 
         * @param boolean $horz Flip along Horizontal Axis
407
 
         * @param boolean $vert Flip along Vertical Axis
408
 
         * @returns boolean|WP_Error
 
414
         * @param bool $horz Flip along Horizontal Axis
 
415
         * @param bool $vert Flip along Vertical Axis
 
416
         * @return true|WP_Error
409
417
         */
410
418
        public function flip( $horz, $vert ) {
411
419
                try {
449
457
                return $saved;
450
458
        }
451
459
 
 
460
        /**
 
461
         *
 
462
         * @param Imagick $image
 
463
         * @param string $filename
 
464
         * @param string $mime_type
 
465
         * @return array|WP_Error
 
466
         */
452
467
        protected function _save( $image, $filename = null, $mime_type = null ) {
453
468
                list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
454
469
 
491
506
         * @access public
492
507
         *
493
508
         * @param string $mime_type
494
 
         * @return boolean|WP_Error
 
509
         * @return true|WP_Error
495
510
         */
496
511
        public function stream( $mime_type = null ) {
497
512
                list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type );