Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
image_converter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef PAGESPEED_KERNEL_IMAGE_IMAGE_CONVERTER_H_
20 #define PAGESPEED_KERNEL_IMAGE_IMAGE_CONVERTER_H_
21 
22 #include <cstddef>
23 #include "third_party/optipng/src/opngreduc/opngreduc.h"
31 
32 namespace net_instaweb {
33 class MessageHandler;
34 }
35 
36 namespace pagespeed {
37 
38 namespace image_compression {
39 
41 
42 class PngReaderInterface;
43 
45  public:
46  enum ImageType {
47  IMAGE_NONE = 0,
48  IMAGE_PNG,
49  IMAGE_JPEG,
50  IMAGE_WEBP
51  };
52 
57  ScanlineWriterInterface* writer);
58 
59  inline static bool ConvertImage(ScanlineReaderInterface* reader,
60  ScanlineWriterInterface* writer) {
61  return ConvertImageWithStatus(reader, writer).Success();
62  }
63 
68  MultipleFrameWriter* writer);
69 
70  static bool ConvertPngToJpeg(
71  const PngReaderInterface& png_struct_reader,
72  const GoogleString& in,
73  const JpegCompressionOptions& options,
74  GoogleString* out,
75  MessageHandler* handler);
76 
83  static bool ConvertPngToWebp(
84  const PngReaderInterface& png_struct_reader,
85  const GoogleString& in,
86  const WebpConfiguration& config,
87  GoogleString* out,
88  bool* is_opaque,
89  MessageHandler* handler);
90 
100  static bool ConvertPngToWebp(
101  const PngReaderInterface& png_struct_reader,
102  const GoogleString& in,
103  const WebpConfiguration& config,
104  GoogleString* out,
105  bool* is_opaque,
106  ScanlineWriterInterface** webp_writer,
107  MessageHandler* handler);
108 
112  static bool OptimizePngOrConvertToJpeg(
113  const PngReaderInterface& png_struct_reader,
114  const GoogleString& in,
115  const JpegCompressionOptions& options,
116  GoogleString* out,
117  bool* is_out_png,
118  MessageHandler* handler);
119 
132  static ImageType GetSmallestOfPngJpegWebp(
134  const PngReaderInterface& png_struct_reader,
135  const GoogleString& in,
136  const JpegCompressionOptions* jpeg_options,
137  const WebpConfiguration* webp_config,
138  GoogleString* out,
139  MessageHandler* handler);
140 
141  private:
142  ImageConverter();
143  ~ImageConverter();
144 
145 
146 };
147 
149 bool GenerateBlankImage(size_t width, size_t height, bool has_transparency,
150  GoogleString* output, MessageHandler* handler);
151 
153 bool ShouldConvertToProgressive(int64 quality, int threshold,
154  int num_bytes, int desired_width,
155  int desired_height);
156 
157 }
158 
159 }
160 
161 #endif
static bool OptimizePngOrConvertToJpeg(const PngReaderInterface &png_struct_reader, const GoogleString &in, const JpegCompressionOptions &options, GoogleString *out, bool *is_out_png, MessageHandler *handler)
Definition: scanline_status.h:93
Definition: image_converter.h:44
Definition: image_frame_interface.h:146
static ImageType GetSmallestOfPngJpegWebp(const PngReaderInterface &png_struct_reader, const GoogleString &in, const JpegCompressionOptions *jpeg_options, const WebpConfiguration *webp_config, GoogleString *out, MessageHandler *handler)
Definition: image_frame_interface.h:279
static ScanlineStatus ConvertMultipleFrameImage(MultipleFrameReader *reader, MultipleFrameWriter *writer)
static bool ConvertPngToWebp(const PngReaderInterface &png_struct_reader, const GoogleString &in, const WebpConfiguration &config, GoogleString *out, bool *is_opaque, MessageHandler *handler)
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
static ScanlineStatus ConvertImageWithStatus(ScanlineReaderInterface *reader, ScanlineWriterInterface *writer)
Definition: message_handler.h:39