Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Static Public Member Functions | List of all members
pagespeed::image_compression::ImageConverter Class Reference

Public Types

enum  ImageType { IMAGE_NONE = 0, IMAGE_PNG, IMAGE_JPEG, IMAGE_WEBP }
 

Static Public Member Functions

static ScanlineStatus ConvertImageWithStatus (ScanlineReaderInterface *reader, ScanlineWriterInterface *writer)
 
static bool ConvertImage (ScanlineReaderInterface *reader, ScanlineWriterInterface *writer)
 
static ScanlineStatus ConvertMultipleFrameImage (MultipleFrameReader *reader, MultipleFrameWriter *writer)
 
static bool ConvertPngToJpeg (const PngReaderInterface &png_struct_reader, const GoogleString &in, const JpegCompressionOptions &options, GoogleString *out, MessageHandler *handler)
 
static bool ConvertPngToWebp (const PngReaderInterface &png_struct_reader, const GoogleString &in, const WebpConfiguration &config, GoogleString *out, bool *is_opaque, MessageHandler *handler)
 
static bool ConvertPngToWebp (const PngReaderInterface &png_struct_reader, const GoogleString &in, const WebpConfiguration &config, GoogleString *out, bool *is_opaque, ScanlineWriterInterface **webp_writer, MessageHandler *handler)
 
static bool OptimizePngOrConvertToJpeg (const PngReaderInterface &png_struct_reader, const GoogleString &in, const JpegCompressionOptions &options, GoogleString *out, bool *is_out_png, MessageHandler *handler)
 
static ImageType GetSmallestOfPngJpegWebp (const PngReaderInterface &png_struct_reader, const GoogleString &in, const JpegCompressionOptions *jpeg_options, const WebpConfiguration *webp_config, GoogleString *out, MessageHandler *handler)
 

Member Function Documentation

static ScanlineStatus pagespeed::image_compression::ImageConverter::ConvertImageWithStatus ( ScanlineReaderInterface reader,
ScanlineWriterInterface writer 
)
static

Converts image one line at a time, between different image formats. Both 'reader' and 'writer' must be non-NULL.

static ScanlineStatus pagespeed::image_compression::ImageConverter::ConvertMultipleFrameImage ( MultipleFrameReader reader,
MultipleFrameWriter writer 
)
static

Converts image frame by frame, and then line by line within each frame, between different image formats. Both 'reader' and 'writer' must be non-NULL.

static bool pagespeed::image_compression::ImageConverter::ConvertPngToWebp ( const PngReaderInterface png_struct_reader,
const GoogleString in,
const WebpConfiguration config,
GoogleString out,
bool *  is_opaque,
MessageHandler handler 
)
static

Reads the PNG encoded in 'in' with 'png_struct_reader', encodes it in WebP format using the options in 'config', and writes the resulting WebP in 'out'. Note that if config.alpha_quality==0, this function will fail when attempting to convert an image with transparent pixels. Returns is_opaque set to true iff the 'in' image was opaque.

static bool pagespeed::image_compression::ImageConverter::ConvertPngToWebp ( const PngReaderInterface png_struct_reader,
const GoogleString in,
const WebpConfiguration config,
GoogleString out,
bool *  is_opaque,
ScanlineWriterInterface **  webp_writer,
MessageHandler handler 
)
static

Reads the PNG encoded in 'in' with 'png_struct_reader', encodes it in WebP format using the options in 'config', and writes the resulting WebP in 'out'. Note that if config.alpha_quality==0, this function will fail when attempting to convert an image with transparent pixels. Returns is_opaque set to true iff the 'in' image was opaque. On entry, '*webp_writer' must be NULL; on exit, it contains the webp writer that was used to write the WebP, and the caller is responsible for deleting it. Most clients will prefer to use the other form ConvertPngToWebp.

static ImageType pagespeed::image_compression::ImageConverter::GetSmallestOfPngJpegWebp ( const PngReaderInterface png_struct_reader,
const GoogleString in,
const JpegCompressionOptions jpeg_options,
const WebpConfiguration webp_config,
GoogleString out,
MessageHandler handler 
)
static

Populates 'out' with a version of the input image 'in' resulting in the smallest size, and returns the corresponding ImageType. The image formats that are candidates for the output image are: lossless WebP, optimized PNG, custom JPEG (if jpeg_options != NULL), and custom WebP (if webp_config != NULL). To compensate for the loss in quality in the custom JPEG and WebP (which are presumably lossy), these two formats must be substantially smaller than the optimized PNG and the lossless WebP in order to be chosen. In the case where none of these image formats could be generated or the original image turns out to be the smallest, copies the original image to 'out' and returns IMAGE_NONE.

Parameters
png_struct_reader
Todo:
TODO(bmcquade): should be a ScanlineReaderInterface.
static bool pagespeed::image_compression::ImageConverter::OptimizePngOrConvertToJpeg ( const PngReaderInterface png_struct_reader,
const GoogleString in,
const JpegCompressionOptions options,
GoogleString out,
bool *  is_out_png,
MessageHandler handler 
)
static

Optimizes the given png image, also converts to jpeg and take the the one that has smaller size and set the output. Returns false if both of them fails.


The documentation for this class was generated from the following file: