mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-19 20:08:28 +01:00
webpmux: add an '-set loop <value>' option
This allows to change the loop count option on animated files. BUG=webp:494 Change-Id: I6849f56d7bff8b33a94f14b409e40f99789009ad
This commit is contained in:
parent
c9a3f6a1d0
commit
cccf5e337a
@ -44,6 +44,7 @@ GET_OPTIONS:
|
||||
|
||||
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
|
||||
|
@ -26,6 +26,7 @@
|
||||
webpmux -set icc image_profile.icc in.webp -o out_icc_container.webp
|
||||
webpmux -set exif image_metadata.exif in.webp -o out_exif_container.webp
|
||||
webpmux -set xmp image_metadata.xmp in.webp -o out_xmp_container.webp
|
||||
webpmux -set loop 1 in.webp -o out_looped.webp
|
||||
|
||||
Extract relevant data from WebP container file:
|
||||
webpmux -get frame n in.webp -o out_frame.webp
|
||||
@ -97,6 +98,7 @@ typedef enum {
|
||||
FEATURE_ICCP,
|
||||
FEATURE_ANMF,
|
||||
FEATURE_DURATION,
|
||||
FEATURE_LOOP,
|
||||
LAST_FEATURE
|
||||
} FeatureType;
|
||||
|
||||
@ -314,6 +316,7 @@ 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");
|
||||
@ -768,6 +771,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], "loop") &&
|
||||
(config->action_type_ == ACTION_SET)) {
|
||||
CHECK_NUM_ARGS_AT_LEAST(2, ErrParse);
|
||||
config->type_ = FEATURE_LOOP;
|
||||
arg->params_ = argv[i + 1];
|
||||
++feature_arg_index;
|
||||
i += 2;
|
||||
} else { // Assume input file.
|
||||
if (config->input_ == NULL) {
|
||||
config->input_ = wargv[i];
|
||||
@ -1018,6 +1028,31 @@ static int Process(const Config* config) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FEATURE_LOOP: {
|
||||
WebPMuxAnimParams params = { 0xFFFFFFFF, 0 };
|
||||
int parse_error = 0;
|
||||
const int loop_count =
|
||||
ExUtilGetInt(config->args_[0].params_, 10, &parse_error);
|
||||
if (loop_count < 0 || loop_count > 65535 || parse_error) {
|
||||
ERROR_GOTO1("ERROR: Loop count must be in the range 0 to 65535.\n",
|
||||
Err2);
|
||||
}
|
||||
ok = CreateMux(config->input_, &mux);
|
||||
if (!ok) goto Err2;
|
||||
ok = (WebPMuxGetAnimationParams(mux, ¶ms) == WEBP_MUX_OK);
|
||||
if (!ok) {
|
||||
ERROR_GOTO1("ERROR: input file does not seem to be an animation.\n",
|
||||
Err2);
|
||||
}
|
||||
params.loop_count = loop_count;
|
||||
err = WebPMuxSetAnimationParams(mux, ¶ms);
|
||||
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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" Hey, EMACS: -*- nroff -*-
|
||||
.TH WEBPMUX 1 "May 1, 2020"
|
||||
.TH WEBPMUX 1 "December 12, 2020"
|
||||
.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.
|
||||
@ -77,6 +77,11 @@ Get nth frame from an animated image. (n = 0 has a special meaning: last frame).
|
||||
|
||||
.SS SET_OPTIONS (\-set)
|
||||
.TP
|
||||
.BI loop " loop_count
|
||||
Set loop count on an animated file.
|
||||
.P
|
||||
Where: 'loop_count' must be in range [0, 65535].
|
||||
.TP
|
||||
.BI icc " file.icc
|
||||
Set ICC profile.
|
||||
.P
|
||||
|
Loading…
Reference in New Issue
Block a user