mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-31 18:35:41 +01:00 
			
		
		
		
	Merge "webpmux: add "-set bgcolor A,R,G,B"" into main
This commit is contained in:
		| @@ -43,8 +43,9 @@ GET_OPTIONS: | ||||
|    frame n   get nth frame | ||||
|  | ||||
| SET_OPTIONS: | ||||
|  Set color profile/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 | ||||
|   | ||||
| @@ -99,6 +99,7 @@ typedef enum { | ||||
|   FEATURE_ANMF, | ||||
|   FEATURE_DURATION, | ||||
|   FEATURE_LOOP, | ||||
|   FEATURE_BGCOLOR, | ||||
|   LAST_FEATURE | ||||
| } FeatureType; | ||||
|  | ||||
| @@ -315,8 +316,9 @@ static void PrintHelp(void) { | ||||
|  | ||||
|   printf("\n"); | ||||
|   printf("SET_OPTIONS:\n"); | ||||
|   printf(" Set color profile/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"); | ||||
| @@ -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, ¶ms) == 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, ¶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 "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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user