Page Speed Optimization Libraries
1.13.35.1
|
#include "image_optimizer.h"
Public Member Functions | |
ImageOptimizer (net_instaweb::MessageHandler *message_handler) | |
bool | Optimize (StringPiece original_contents, GoogleString *optimized_contents, ImageFormat *optimized_format) |
void | set_options (const pagespeed::image_compression::ImageOptions &options) |
void | set_requested_dimension (const pagespeed::image_compression::ImageDimensions &requested_dimensions) |
int | optimized_width () |
int | optimized_height () |
void | set_timer (net_instaweb::Timer *timer) |
Timer and was_timed_out only apply to WebP images. | |
bool | was_timed_out () const |
bool | UsesLossyFormat () const |
Optimizes an image. The supported formats include GIF (both single-frame and animated), PNG, and JPEG. They can be converted to PNG, JPEG, or WebP (including lossy, lossless, or animated WebP). They can be resized to smaller dimensions. You specify the allowed options and the requested dimensions, and the method returns the format, dimensions, and contents for the actual output.
If you specify a timer and the max_timeout_ms parameter, the method applies them to WebP images (other images are not affected by these parameters).
This class can only be used to optimize one image, i.e., an ImageOptimizer object can only have the Optimize method called once.
bool pagespeed::image_compression::ImageOptimizer::Optimize | ( | StringPiece | original_contents, |
GoogleString * | optimized_contents, | ||
ImageFormat * | optimized_format | ||
) |
Applies all optimizations, for example, removing metadata, reducing chroma sampling, and reducing dimension, to the image.
|
inline |
Returns the actual dimensions of the optimized image, even when the image is not resized.
|
inline |
Specifies the dimensions for resizing the image to. This parameter only applies to single-frame images. You can specify either width or height, or both. If you specify only one dimension, the image will be resized with the original aspect ratio. If the dimensions cannot be honored, the image can still be optimized in other ways. You can get the actual dimension of the optimized image by using the OutputDimension method.
|
inline |
Returns whether the image was encoded in lossy format, if the optimization succeeded.