diff --git a/README b/README index 65a015c8..4896b24d 100644 --- a/README +++ b/README @@ -168,7 +168,7 @@ options: -noalpha ............... discard any transparency information. -lossless .............. Encode image losslessly. -hint ......... Specify image characteristics hint. - One of: photo or picture + One of: photo, picture or graph. -short ................. condense printed message -quiet ................. don't print anything. diff --git a/examples/cwebp.c b/examples/cwebp.c index 2ca8d7e2..2348d272 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -844,7 +844,7 @@ static void HelpLong(void) { printf(" -noalpha ............... discard any transparency information.\n"); printf(" -lossless .............. Encode image losslessly.\n"); printf(" -hint ......... Specify image characteristics hint.\n"); - printf(" One of: photo or picture\n"); + printf(" One of: photo, picture or graph\n"); printf("\n"); printf(" -short ................. condense printed message\n"); @@ -973,6 +973,8 @@ int main(int argc, const char *argv[]) { config.image_hint = WEBP_HINT_PHOTO; } else if (!strcmp(argv[c], "picture")) { config.image_hint = WEBP_HINT_PICTURE; + } else if (!strcmp(argv[c], "graph")) { + config.image_hint = WEBP_HINT_GRAPH; } else { fprintf(stderr, "Error! Unrecognized image hint: %s\n", argv[c]); goto Error; diff --git a/man/cwebp.1 b/man/cwebp.1 index 181c315e..fab8517e 100644 --- a/man/cwebp.1 +++ b/man/cwebp.1 @@ -164,7 +164,7 @@ Encode the image without any loss. .TP .B \-hint string Specify the hint about input image type. Possible values are: -\fBphoto\fP, and \fBpicture\fP. +\fBphoto\fP, \fBpicture\fP or \fBgraph\fP. .TP .B \-noasm Disable all assembly optimizations. diff --git a/src/enc/config.c b/src/enc/config.c index fa11e89a..1a261135 100644 --- a/src/enc/config.c +++ b/src/enc/config.c @@ -120,7 +120,7 @@ int WebPValidateConfig(const WebPConfig* config) { return 0; if (config->lossless < 0 || config->lossless > 1) return 0; - if (config->image_hint > WEBP_HINT_PHOTO) + if (config->image_hint >= WEBP_HINT_LAST) return 0; return 1; } diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c index 82bef500..f40b5e3f 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -141,7 +141,7 @@ static int VP8LEncAnalyze(VP8LEncoder* const enc, WebPImageHint image_hint) { const WebPPicture* const pic = enc->pic_; assert(pic != NULL && pic->argb != NULL); - enc->use_palette_ = + enc->use_palette_ = (image_hint == WEBP_HINT_GRAPH) ? 0 : AnalyzeAndCreatePalette(pic, enc->palette_, &enc->palette_size_); if (!enc->use_palette_) { if (image_hint == WEBP_HINT_DEFAULT) { @@ -162,7 +162,6 @@ static int VP8LEncAnalyze(VP8LEncoder* const enc, WebPImageHint image_hint) { return 1; } - static int GetHuffBitLengthsAndCodes( const VP8LHistogramSet* const histogram_image, HuffmanTreeCode* const huffman_codes) { diff --git a/src/webp/encode.h b/src/webp/encode.h index 1ee42819..8c89626c 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -69,7 +69,9 @@ WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra, typedef enum { WEBP_HINT_DEFAULT = 0, // default preset. WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot - WEBP_HINT_PHOTO // outdoor photograph, with natural lighting + WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting + WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc). + WEBP_HINT_LAST } WebPImageHint; typedef struct {