19 #ifndef PAGESPEED_KERNEL_IMAGE_IMAGE_OPTIMIZER_H_
20 #define PAGESPEED_KERNEL_IMAGE_IMAGE_OPTIMIZER_H_
28 #include "pagespeed/kernel/http/image_types.pb.h"
29 #include "pagespeed/kernel/image/image_optimizer.pb.h"
32 namespace net_instaweb {
38 namespace image_compression {
56 message_handler_(message_handler) {
65 bool Optimize(StringPiece original_contents,
67 ImageFormat* optimized_format);
69 void set_options(
const pagespeed::image_compression::ImageOptions& options) {
80 const pagespeed::image_compression::ImageDimensions&
81 requested_dimensions) {
82 requested_dim_ = requested_dimensions;
88 int optimized_height() {
return optimized_height_; }
92 bool was_timed_out()
const {
return was_timed_out_; }
100 bool ComputeDesiredFormat();
101 bool ComputeResizedDimension();
102 bool ComputeDesiredQualityProgressive();
103 ImageFormat ImageTypeToImageFormat(net_instaweb::ImageType image_type);
104 bool ConfigureWriter();
105 bool RewriteSingleFrameImage();
106 bool RewriteAnimatedImage();
110 pagespeed::image_compression::ImageOptions options_;
111 StringPiece original_contents_;
112 pagespeed::image_compression::ImageDimensions requested_dim_;
115 std::unique_ptr<ConversionTimeoutHandler> timeout_handler_;
116 bool was_timed_out_ =
false;
119 ImageFormat original_format_;
120 int original_width_ = -1;
121 int original_height_ = -1;
122 bool is_progressive_ =
false;
123 bool is_animated_ =
false;
124 bool is_transparent_ =
false;
125 bool is_photo_ =
false;
126 int original_quality_ = -1;
129 ImageFormat optimized_format_;
130 int optimized_width_ = -1;
131 int optimized_height_ = -1;
132 int desired_quality_ = -1;
133 bool desired_progressive_ =
false;
134 bool desired_lossless_ =
false;
135 std::unique_ptr<ScanlineWriterConfig> writer_config_;
136 bool is_valid_ =
true;
void set_requested_dimension(const pagespeed::image_compression::ImageDimensions &requested_dimensions)
Definition: image_optimizer.h:79
int optimized_width()
Definition: image_optimizer.h:87
Definition: image_optimizer.h:53
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
bool UsesLossyFormat() const
Definition: image_optimizer.h:96
void set_timer(net_instaweb::Timer *timer)
Timer and was_timed_out only apply to WebP images.
Definition: image_optimizer.h:91
bool Optimize(StringPiece original_contents, GoogleString *optimized_contents, ImageFormat *optimized_format)
Definition: message_handler.h:39
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27