equal
deleted
inserted
replaced
127 if ( $this->image instanceof Imagick ) { |
127 if ( $this->image instanceof Imagick ) { |
128 return true; |
128 return true; |
129 } |
129 } |
130 |
130 |
131 if ( ! is_file( $this->file ) && ! wp_is_stream( $this->file ) ) { |
131 if ( ! is_file( $this->file ) && ! wp_is_stream( $this->file ) ) { |
132 return new WP_Error( 'error_loading_image', __( 'File doesn’t exist?' ), $this->file ); |
132 return new WP_Error( 'error_loading_image', __( 'File does not exist?' ), $this->file ); |
133 } |
133 } |
134 |
134 |
135 /* |
135 /* |
136 * Even though Imagick uses less PHP memory than GD, set higher limit |
136 * Even though Imagick uses less PHP memory than GD, set higher limit |
137 * for users that have low PHP.ini limits. |
137 * for users that have low PHP.ini limits. |
442 * |
442 * |
443 * Either a height or width must be provided. |
443 * Either a height or width must be provided. |
444 * If one of the two is set to null, the resize will |
444 * If one of the two is set to null, the resize will |
445 * maintain aspect ratio according to the provided dimension. |
445 * maintain aspect ratio according to the provided dimension. |
446 * |
446 * |
447 * @type array $size { |
447 * @type array ...$0 { |
448 * Array of height, width values, and whether to crop. |
448 * Array of height, width values, and whether to crop. |
449 * |
449 * |
450 * @type int $width Image width. Optional if `$height` is specified. |
450 * @type int $width Image width. Optional if `$height` is specified. |
451 * @type int $height Image height. Optional if `$width` is specified. |
451 * @type int $height Image height. Optional if `$width` is specified. |
452 * @type bool $crop Optional. Whether to crop the image. Default false. |
452 * @type bool $crop Optional. Whether to crop the image. Default false. |
587 * (GD rotates counter-clockwise) |
587 * (GD rotates counter-clockwise) |
588 */ |
588 */ |
589 try { |
589 try { |
590 $this->image->rotateImage( new ImagickPixel( 'none' ), 360 - $angle ); |
590 $this->image->rotateImage( new ImagickPixel( 'none' ), 360 - $angle ); |
591 |
591 |
592 // Normalise EXIF orientation data so that display is consistent across devices. |
592 // Normalize EXIF orientation data so that display is consistent across devices. |
593 if ( is_callable( array( $this->image, 'setImageOrientation' ) ) && defined( 'Imagick::ORIENTATION_TOPLEFT' ) ) { |
593 if ( is_callable( array( $this->image, 'setImageOrientation' ) ) && defined( 'Imagick::ORIENTATION_TOPLEFT' ) ) { |
594 $this->image->setImageOrientation( Imagick::ORIENTATION_TOPLEFT ); |
594 $this->image->setImageOrientation( Imagick::ORIENTATION_TOPLEFT ); |
595 } |
595 } |
596 |
596 |
597 // Since this changes the dimensions of the image, update the size. |
597 // Since this changes the dimensions of the image, update the size. |
625 |
625 |
626 if ( $vert ) { |
626 if ( $vert ) { |
627 $this->image->flopImage(); |
627 $this->image->flopImage(); |
628 } |
628 } |
629 |
629 |
630 // Normalise EXIF orientation data so that display is consistent across devices. |
630 // Normalize EXIF orientation data so that display is consistent across devices. |
631 if ( is_callable( array( $this->image, 'setImageOrientation' ) ) && defined( 'Imagick::ORIENTATION_TOPLEFT' ) ) { |
631 if ( is_callable( array( $this->image, 'setImageOrientation' ) ) && defined( 'Imagick::ORIENTATION_TOPLEFT' ) ) { |
632 $this->image->setImageOrientation( Imagick::ORIENTATION_TOPLEFT ); |
632 $this->image->setImageOrientation( Imagick::ORIENTATION_TOPLEFT ); |
633 } |
633 } |
634 } catch ( Exception $e ) { |
634 } catch ( Exception $e ) { |
635 return new WP_Error( 'image_flip_error', $e->getMessage() ); |
635 return new WP_Error( 'image_flip_error', $e->getMessage() ); |
660 /** |
660 /** |
661 * Saves current image to file. |
661 * Saves current image to file. |
662 * |
662 * |
663 * @since 3.5.0 |
663 * @since 3.5.0 |
664 * |
664 * |
665 * @param string $destfilename |
665 * @param string $destfilename Optional. Destination filename. Default null. |
666 * @param string $mime_type |
666 * @param string $mime_type Optional. The mime-type. Default null. |
667 * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string} |
667 * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string} |
668 */ |
668 */ |
669 public function save( $destfilename = null, $mime_type = null ) { |
669 public function save( $destfilename = null, $mime_type = null ) { |
670 $saved = $this->_save( $this->image, $destfilename, $mime_type ); |
670 $saved = $this->_save( $this->image, $destfilename, $mime_type ); |
671 |
671 |
727 /** This filter is documented in wp-includes/class-wp-image-editor-gd.php */ |
727 /** This filter is documented in wp-includes/class-wp-image-editor-gd.php */ |
728 'file' => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ), |
728 'file' => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ), |
729 'width' => $this->size['width'], |
729 'width' => $this->size['width'], |
730 'height' => $this->size['height'], |
730 'height' => $this->size['height'], |
731 'mime-type' => $mime_type, |
731 'mime-type' => $mime_type, |
|
732 'filesize' => wp_filesize( $filename ), |
732 ); |
733 ); |
733 } |
734 } |
734 |
735 |
735 /** |
736 /** |
736 * Writes an image to a file or stream. |
737 * Writes an image to a file or stream. |
899 * Includes a workaround for a bug in Ghostscript 8.70 that prevents processing of some PDF files |
900 * Includes a workaround for a bug in Ghostscript 8.70 that prevents processing of some PDF files |
900 * when `use-cropbox` is set. |
901 * when `use-cropbox` is set. |
901 * |
902 * |
902 * @since 5.6.0 |
903 * @since 5.6.0 |
903 * |
904 * |
904 * @return true|WP_error |
905 * @return true|WP_Error |
905 */ |
906 */ |
906 protected function pdf_load_source() { |
907 protected function pdf_load_source() { |
907 $filename = $this->pdf_setup(); |
908 $filename = $this->pdf_setup(); |
908 |
909 |
909 if ( is_wp_error( $filename ) ) { |
910 if ( is_wp_error( $filename ) ) { |