update_size example

$size = wp_getimagesize( $this->file );

        if ( ! $size ) {
            return new WP_Error( 'invalid_image', __( 'Could not read image size.' )$this->file );
        }

        if ( function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) {
            imagealphablending( $this->image, false );
            imagesavealpha( $this->image, true );
        }

        $this->update_size( $size[0]$size[1] );
        $this->mime_type = $size['mime'];

        return $this->set_quality();
    }

    /** * Sets or updates current image size. * * @since 3.5.0 * * @param int $width * @param int $height * @return true */
// Select the first frame to handle animated images properly.             if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) {
                $this->image->setIteratorIndex( 0 );
            }

            $this->mime_type = $this->get_mime_type( $this->image->getImageFormat() );
        } catch ( Exception $e ) {
            return new WP_Error( 'invalid_image', $e->getMessage()$this->file );
        }

        $updated_size = $this->update_size();

        if ( is_wp_error( $updated_size ) ) {
            return $updated_size;
        }

        return $this->set_quality();
    }

    /** * Sets Image Compression quality on a 1-100% scale. * * @since 3.5.0 * * @param int $quality Compression Quality. Range: [1,100] * @return true|WP_Error True if set successfully; WP_Error on failure. */
Home | Imprint | This part of the site doesn't use cookies.