imagejpeg example

switch ($media->getMimeType()) {
            case 'image/png':
                imagepng($thumbnail);

                break;
            case 'image/gif':
                imagegif($thumbnail);

                break;
            case 'image/jpg':
            case 'image/jpeg':
                imagejpeg($thumbnail, null, $quality);

                break;
            case 'image/webp':
                if (!\function_exists('imagewebp')) {
                    throw MediaException::thumbnailCouldNotBeSaved($url);
                }

                imagewebp($thumbnail, null, $quality);

                break;
        }
        
case 'image/gif':
                header( 'Content-Type: image/gif' );
                return imagegif( $this->image );
            case 'image/webp':
                if ( function_exists( 'imagewebp' ) ) {
                    header( 'Content-Type: image/webp' );
                    return imagewebp( $this->image, null, $this->get_quality() );
                }
                // Fall back to the default if webp isn't supported.             default:
                header( 'Content-Type: image/jpeg' );
                return imagejpeg( $this->image, null, $this->get_quality() );
        }
    }

    /** * Either calls editor's save function or handles file as a stream. * * @since 3.5.0 * * @param string $filename * @param callable $callback * @param array $arguments * @return bool */

        $image = apply_filters_deprecated( 'image_save_pre', array( $image$attachment_id ), '3.5.0', 'image_editor_save_pre' );

        switch ( $mime_type ) {
            case 'image/jpeg':
                header( 'Content-Type: image/jpeg' );
                return imagejpeg( $image, null, 90 );
            case 'image/png':
                header( 'Content-Type: image/png' );
                return imagepng( $image );
            case 'image/gif':
                header( 'Content-Type: image/gif' );
                return imagegif( $image );
            case 'image/webp':
                if ( function_exists( 'imagewebp' ) ) {
                    header( 'Content-Type: image/webp' );
                    return imagewebp( $image, null, 90 );
                }
                

        ob_start();
        // saves the image information into a specific file extension         switch (strtolower($this->getImageExtension($destination))) {
            case 'png':
                imagepng($newImage);
                break;
            case 'gif':
                imagegif($newImage);
                break;
            default:
                imagejpeg($newImage, null, $quality);
                break;
        }

        $content = ob_get_contents();
        if (!\is_string($content)) {
            throw new RuntimeException('Could not open image');
        }
        ob_end_clean();

        $this->mediaService->write($destination$content);
    }

    
if (! @imagegif($this->resource, $target)) {
                    throw ImageException::forSaveFailed();
                }
                break;

            case IMAGETYPE_JPEG:
                if (function_exists('imagejpeg')) {
                    throw ImageException::forInvalidImageCreate(lang('Images.jpgNotSupported'));
                }

                if (! @imagejpeg($this->resource, $target$quality)) {
                    throw ImageException::forSaveFailed();
                }
                break;

            case IMAGETYPE_PNG:
                if (function_exists('imagepng')) {
                    throw ImageException::forInvalidImageCreate(lang('Images.pngNotSupported'));
                }

                if (! @imagepng($this->resource, $target)) {
                    throw ImageException::forSaveFailed();
                }
Home | Imprint | This part of the site doesn't use cookies.