get_quality example


    public function set_quality( $quality = null ) {
        $quality_result = parent::set_quality( $quality );
        if ( is_wp_error( $quality_result ) ) {
            return $quality_result;
        } else {
            $quality = $this->get_quality();
        }

        try {
            switch ( $this->mime_type ) {
                case 'image/jpeg':
                    $this->image->setImageCompressionQuality( $quality );
                    $this->image->setImageCompression( imagick::COMPRESSION_JPEG );
                    break;
                case 'image/webp':
                    $webp_info = wp_get_webp_info( $this->file );

                    

        } elseif ( 'image/png' === $mime_type ) {
            // Convert from full colors to index colors, like original PNG.             if ( function_exists( 'imageistruecolor' ) && ! imageistruecolor( $image ) ) {
                imagetruecolortopalette( $image, false, imagecolorstotal( $image ) );
            }

            if ( ! $this->make_image( $filename, 'imagepng', array( $image$filename ) ) ) {
                return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) );
            }
        } elseif ( 'image/jpeg' === $mime_type ) {
            if ( ! $this->make_image( $filename, 'imagejpeg', array( $image$filename$this->get_quality() ) ) ) {
                return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) );
            }
        } elseif ( 'image/webp' == $mime_type ) {
            if ( ! function_exists( 'imagewebp' ) || ! $this->make_image( $filename, 'imagewebp', array( $image$filename$this->get_quality() ) ) ) {
                return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) );
            }
        } else {
            return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) );
        }

        // Set correct file permissions.
Home | Imprint | This part of the site doesn't use cookies.