WP_Image_Editor_Imagick::save( string $destfilename = null, string $mime_type = null ): array|WP_Error

Saves current image to file.


Parameters

$destfilename string Optional
Destination filename.

Default: null

$mime_type string Optional
The mime-type.

Default: null


Top ↑

Return

array|WP_Error Array on success or WP_Error if the file failed to save.

  • path string
    Path to the image file.
  • file string
    Name of the image file.
  • width int
    Image width.
  • height int
    Image height.
  • mime-type string
    The mime type of the image.
  • filesize int
    File size of the image.


Top ↑

Source

File: wp-includes/class-wp-image-editor-imagick.php. View all references

public function save( $destfilename = null, $mime_type = null ) {
	$saved = $this->_save( $this->image, $destfilename, $mime_type );

	if ( ! is_wp_error( $saved ) ) {
		$this->file      = $saved['path'];
		$this->mime_type = $saved['mime-type'];

		try {
			$this->image->setImageFormat( strtoupper( $this->get_extension( $this->mime_type ) ) );
		} catch ( Exception $e ) {
			return new WP_Error( 'image_save_error', $e->getMessage(), $this->file );
		}
	}

	return $saved;
}


Top ↑

Changelog

Changelog
Version Description
6.0.0 The $filesize value was added to the returned array.
3.5.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.