diff --git a/README.mux b/README.mux index a5a87d49..ff157a81 100644 --- a/README.mux +++ b/README.mux @@ -56,11 +56,12 @@ STRIP_OPTIONS: FRAME_OPTIONS(i): Create animation. - file_i +di+xi+yi+mi + file_i +di+[xi+yi[+mi[bi]]] where: 'file_i' is the i'th animation frame (WebP format), 'di' is the pause duration before next frame. 'xi','yi' specify the image offset for this frame. 'mi' is the dispose method for this frame (0 or 1). + 'bi' is the blending method for this frame (+b or -b). LOOP_COUNT: Number of times to repeat the animation. diff --git a/examples/webpmux.c b/examples/webpmux.c index e8afe3ad..a9709677 100644 --- a/examples/webpmux.c +++ b/examples/webpmux.c @@ -228,14 +228,17 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) { if (nFrames > 0) { int i; printf("No.: x_offset y_offset "); - if (is_anim) printf("duration dispose "); + if (is_anim) printf("duration dispose blend "); printf("image_size\n"); for (i = 1; i <= nFrames; i++) { WebPMuxFrameInfo frame; err = WebPMuxGetFrame(mux, i, &frame); if (err == WEBP_MUX_OK) { printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset); - if (is_anim) printf("%8d %7d ", frame.duration, frame.dispose_method); + if (is_anim) { + printf("%8d %7d %5d", frame.duration, frame.dispose_method, + frame.blend_method); + } printf("%10d\n", (int)frame.bitstream.size); } WebPDataClear(&frame.bitstream); @@ -333,11 +336,13 @@ static void PrintHelp(void) { printf("\n"); printf("FRAME_OPTIONS(i):\n"); printf(" Create animation.\n"); - printf(" file_i +di+xi+yi+mi\n"); + printf(" file_i +di+[xi+yi[+mi[bi]]]\n"); printf(" where: 'file_i' is the i'th animation frame (WebP format),\n"); printf(" 'di' is the pause duration before next frame.\n"); printf(" 'xi','yi' specify the image offset for this frame.\n"); printf(" 'mi' is the dispose method for this frame (0 or 1).\n"); + printf(" 'bi' is the blending method for this frame (+b or -b)." + "\n"); printf("\n"); printf("LOOP_COUNT:\n"); @@ -414,24 +419,33 @@ static int WriteWebP(WebPMux* const mux, const char* filename) { static int ParseFrameArgs(const char* args, WebPMuxFrameInfo* const info) { int dispose_method, dummy; - const int num_args = sscanf(args, "+%d+%d+%d+%d+%d", - &info->duration, &info->x_offset, &info->y_offset, - &dispose_method, &dummy); + char plus_minus, blend_method; + const int num_args = sscanf(args, "+%d+%d+%d+%d%c%c+%d", &info->duration, + &info->x_offset, &info->y_offset, &dispose_method, + &plus_minus, &blend_method, &dummy); switch (num_args) { case 1: info->x_offset = info->y_offset = 0; // fall through case 3: dispose_method = 0; // fall through case 4: + plus_minus = '+'; + blend_method = 'b'; // fall through + case 6: break; + case 2: + case 5: default: return 0; } // Note: The sanity of the following conversion is checked by - // WebPMuxSetAnimationParams(). + // WebPMuxPushFrame(). info->dispose_method = (WebPMuxAnimDispose)dispose_method; - // TODO(urvang): Add support for parsing blending method too. - info->blend_method = WEBP_MUX_BLEND; + + if (blend_method != 'b') return 0; + if (plus_minus != '-' && plus_minus != '+') return 0; + info->blend_method = + (plus_minus == '+') ? WEBP_MUX_BLEND : WEBP_MUX_NO_BLEND; return 1; } diff --git a/man/webpmux.1 b/man/webpmux.1 index 393c3f82..02d13a1c 100644 --- a/man/webpmux.1 +++ b/man/webpmux.1 @@ -1,5 +1,5 @@ .\" Hey, EMACS: -*- nroff -*- -.TH WEBPMUX 1 "March 16, 2013" +.TH WEBPMUX 1 "August 26, 2013" .SH NAME webpmux \- command line tool to create WebP Mux/container file. .SH SYNOPSIS @@ -92,12 +92,14 @@ Strip XMP metadata. .SS FRAME_OPTIONS (\-frame) .TP -.I file_i +di[+xi+yi[+mi]] +.I file_i +di[+xi+yi[+mi[bi]]] Where: 'file_i' is the i'th frame (WebP format), 'xi','yi' specify the image -offset for this frame, 'di' is the pause duration before next frame and 'mi' is -the dispose method for this frame (0 for NONE or 1 for BACKGROUND). -'mi' can be omitted and will default to 0 (NONE). -Additionally, if 'mi' is ommitted then'xi' and 'yi' can be omitted and will +offset for this frame, 'di' is the pause duration before next frame, 'mi' is +the dispose method for this frame (0 for NONE or 1 for BACKGROUND) and 'bi' is +the blending method for this frame (+b for BLEND or -b for NO_BLEND). +Argument 'bi' can be omitted and will default to +b (BLEND). +Also, 'mi' can be omitted if 'bi' is omitted and will default to 0 (NONE). +Finally, if 'mi' and 'bi' are omitted then 'xi' and 'yi' can be omitted and will default to +0+0. .TP .BI \-loop " n @@ -149,10 +151,13 @@ webpmux \-get exif exif_container.webp \-o image_metadata.exif .br webpmux \-strip exif exif_container.webp \-o without_exif.webp .br -webpmux \-frame anim_1.webp +100 \-frame anim_2.webp +100+50+50 \-loop 10 +webpmux \-frame anim_1.webp +100 \-frame anim_2.webp +100+50+50 .br .RS 8 -\-bgcolor 255,255,255,255 \-o anim_container.webp +\-frame anim_2.webp +100+50+50+1+b \-loop 10 \-bgcolor 255,255,255,255 +.br +.RS 8 +\-o anim_container.webp .RE .br webpmux \-get frame 2 anim_container.webp \-o frame_2.webp