aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Massimino <pascal.massimino@gmail.com>2021-11-04 19:00:36 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-11-04 19:00:36 +0000
commit3368d8768a21b978bf94bb4485f7fef38e77a6f9 (patch)
tree47d3b970311f5851c3f9f8d64cf3f77d625e0a69
parentf213abf620183f8ae6f51da86d53c03c245ff5b8 (diff)
parent50c97c301d7c958f1c76bf38c908f16f2d3ba1a3 (diff)
downloadwebp-3368d8768a21b978bf94bb4485f7fef38e77a6f9.tar.gz
Merge "webpmux: add "-set bgcolor A,R,G,B"" into main
-rw-r--r--README.mux11
-rw-r--r--examples/webpmux.c43
-rw-r--r--man/webpmux.17
3 files changed, 50 insertions, 11 deletions
diff --git a/README.mux b/README.mux
index bcc458bd..1926d142 100644
--- a/README.mux
+++ b/README.mux
@@ -43,11 +43,12 @@ GET_OPTIONS:
frame n get nth frame
SET_OPTIONS:
- Set color profile/metadata:
- loop LOOP_COUNT set the loop count
- icc file.icc set ICC profile
- exif file.exif set EXIF metadata
- xmp file.xmp set XMP metadata
+ Set color profile/metadata/parameters:
+ loop LOOP_COUNT set the loop count
+ bgcolor BACKGROUND_COLOR set the animation background color
+ icc file.icc set ICC profile
+ exif file.exif set EXIF metadata
+ xmp file.xmp set XMP metadata
where: 'file.icc' contains the ICC profile to be set,
'file.exif' contains the EXIF metadata to be set
'file.xmp' contains the XMP metadata to be set
diff --git a/examples/webpmux.c b/examples/webpmux.c
index fc72a90c..b37d8c5e 100644
--- a/examples/webpmux.c
+++ b/examples/webpmux.c
@@ -99,6 +99,7 @@ typedef enum {
FEATURE_ANMF,
FEATURE_DURATION,
FEATURE_LOOP,
+ FEATURE_BGCOLOR,
LAST_FEATURE
} FeatureType;
@@ -315,11 +316,12 @@ static void PrintHelp(void) {
printf("\n");
printf("SET_OPTIONS:\n");
- printf(" Set color profile/metadata:\n");
- printf(" loop LOOP_COUNT set the loop count\n");
- printf(" icc file.icc set ICC profile\n");
- printf(" exif file.exif set EXIF metadata\n");
- printf(" xmp file.xmp set XMP metadata\n");
+ printf(" Set color profile/metadata/parameters:\n");
+ printf(" loop LOOP_COUNT set the loop count\n");
+ printf(" bgcolor BACKGROUND_COLOR set the animation background color\n");
+ printf(" icc file.icc set ICC profile\n");
+ printf(" exif file.exif set EXIF metadata\n");
+ printf(" xmp file.xmp set XMP metadata\n");
printf(" where: 'file.icc' contains the ICC profile to be set,\n");
printf(" 'file.exif' contains the EXIF metadata to be set\n");
printf(" 'file.xmp' contains the XMP metadata to be set\n");
@@ -778,6 +780,13 @@ static int ParseCommandLine(Config* config, const W_CHAR** const unicode_argv) {
arg->params_ = argv[i + 1];
++feature_arg_index;
i += 2;
+ } else if (!strcmp(argv[i], "bgcolor") &&
+ (config->action_type_ == ACTION_SET)) {
+ CHECK_NUM_ARGS_AT_LEAST(2, ErrParse);
+ config->type_ = FEATURE_BGCOLOR;
+ arg->params_ = argv[i + 1];
+ ++feature_arg_index;
+ i += 2;
} else { // Assume input file.
if (config->input_ == NULL) {
config->input_ = wargv[i];
@@ -1053,6 +1062,30 @@ static int Process(const Config* config) {
}
break;
}
+ case FEATURE_BGCOLOR: {
+ WebPMuxAnimParams params = { 0xFFFFFFFF, 0 };
+ uint32_t bgcolor;
+ ok = ParseBgcolorArgs(config->args_[0].params_, &bgcolor);
+ if (!ok) {
+ ERROR_GOTO1("ERROR: Could not parse the background color.\n",
+ Err2);
+ }
+ ok = CreateMux(config->input_, &mux);
+ if (!ok) goto Err2;
+ ok = (WebPMuxGetAnimationParams(mux, &params) == WEBP_MUX_OK);
+ if (!ok) {
+ ERROR_GOTO1("ERROR: input file does not seem to be an animation.\n",
+ Err2);
+ }
+ params.bgcolor = bgcolor;
+ err = WebPMuxSetAnimationParams(mux, &params);
+ ok = (err == WEBP_MUX_OK);
+ if (!ok) {
+ ERROR_GOTO2("ERROR (%s): Could not set animation parameters.\n",
+ ErrorString(err), Err2);
+ }
+ break;
+ }
default: {
ERROR_GOTO1("ERROR: Invalid feature for action 'set'.\n", Err2);
break;
diff --git a/man/webpmux.1 b/man/webpmux.1
index 2484b391..1ea29954 100644
--- a/man/webpmux.1
+++ b/man/webpmux.1
@@ -1,5 +1,5 @@
.\" Hey, EMACS: -*- nroff -*-
-.TH WEBPMUX 1 "December 12, 2020"
+.TH WEBPMUX 1 "November 3, 2021"
.SH NAME
webpmux \- create animated WebP files from non\-animated WebP images, extract
frames from animated WebP images, and manage XMP/EXIF metadata and ICC profile.
@@ -82,6 +82,11 @@ Set loop count on an animated file.
.P
Where: 'loop_count' must be in range [0, 65535].
.TP
+.BI bgcolor " A,R,G,B
+Set the background color of the canvas on an animated file.
+.P
+Where: 'loop_count' must be in range [0, 65535].
+.TP
.BI icc " file.icc
Set ICC profile.
.P