WP_Image_Editor_Imagick::save() WordPress Method

The WP_Image_Editor_Imagick::save() method is used to save an image to a file. This method can be used to save an image to a new file or to overwrite an existing file.

WP_Image_Editor_Imagick::save( string $destfilename = null, string $mime_type = null ) #

Saves current image to file.


Parameters

$destfilename

(string)(Optional) Destination filename.

Default value: null

$mime_type

(string)(Optional) The mime-type.

Default value: null


Top ↑

Return

(array|WP_Error) 'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string


Top ↑

Source

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

	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
VersionDescription
3.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.