setImageFormat example


    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;
    }

    /** * @since 3.5.0 * @since 6.0.0 The `$filesize` value was added to the returned array. * * @param Imagick $image * @param string $filename * @param string $mime_type * @return array|WP_Error { * Array on success or WP_Error if the file failed to save. * * @type string $path Path to the image file. * @type string $file Name of the image file. * @type int $width Image width. * @type int $height Image height. * @type string $mime-type The mime type of the image. * @type int $filesize File size of the image. * } */
Home | Imprint | This part of the site doesn't use cookies.