mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-12 22:14:29 +02:00
gif2webp: add support for reading from stdin
output to stdout is already supported; this matches [cd]webp BUG=webp:371 Change-Id: Ib1ce1661b16ea792943bca2980f779584e90cc86
This commit is contained in:
committed by
Pascal Massimino
parent
cf1c5054c7
commit
cbde5728c8
@ -23,6 +23,10 @@
|
||||
|
||||
#ifdef WEBP_HAVE_GIF
|
||||
|
||||
#if defined(HAVE_UNISTD_H) && HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <gif_lib.h>
|
||||
#include "webp/encode.h"
|
||||
#include "webp/mux.h"
|
||||
@ -30,6 +34,10 @@
|
||||
#include "../imageio/imageio_util.h"
|
||||
#include "./gifdec.h"
|
||||
|
||||
#if !defined(STDIN_FILENO)
|
||||
#define STDIN_FILENO 0
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static int transparent_index = GIF_INDEX_INVALID; // Opaque by default.
|
||||
@ -263,9 +271,11 @@ int main(int argc, const char *argv[]) {
|
||||
|
||||
// Start the decoder object
|
||||
#if LOCAL_GIF_PREREQ(5,0)
|
||||
gif = DGifOpenFileName(in_file, &gif_error);
|
||||
gif = !strcmp(in_file, "-") ? DGifOpenFileHandle(STDIN_FILENO, &gif_error)
|
||||
: DGifOpenFileName(in_file, &gif_error);
|
||||
#else
|
||||
gif = DGifOpenFileName(in_file);
|
||||
gif = !strcmp(in_file, "-") ? DGifOpenFileHandle(STDIN_FILENO)
|
||||
: DGifOpenFileName(in_file);
|
||||
#endif
|
||||
if (gif == NULL) goto End;
|
||||
|
||||
@ -532,8 +542,13 @@ int main(int argc, const char *argv[]) {
|
||||
goto End;
|
||||
}
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "Saved output file (%d bytes): %s\n",
|
||||
(int)webp_data.size, out_file);
|
||||
if (!strcmp(out_file, "-")) {
|
||||
fprintf(stderr, "Saved %d bytes to STDIO\n",
|
||||
(int)webp_data.size);
|
||||
} else {
|
||||
fprintf(stderr, "Saved output file (%d bytes): %s\n",
|
||||
(int)webp_data.size, out_file);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!quiet) {
|
||||
|
Reference in New Issue
Block a user