--- Makefile | 6 ++++-- ffinfo.1 | 47 +++++++++++++++++++++++++++++++++++++++++++++++ ffinfo.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 ffinfo.1 create mode 100644 ffinfo.c diff --git a/Makefile b/Makefile index 120ce25..e10c475 100644 --- a/Makefile +++ b/Makefile _AT_@ -6,7 +6,7 @@ include config.mk REQ = util HDR = arg.h -BIN = png2ff ff2png jpg2ff ff2jpg ff2pam ff2ppm +BIN = png2ff ff2png jpg2ff ff2jpg ff2pam ff2ppm ffinfo SCR = 2ff MAN1 = 2ff.1 $(BIN:=.1) MAN5 = farbfeld.5 _AT_@ -24,6 +24,7 @@ jpg2ff: jpg2ff.o $(REQ:=.o) ff2jpg: ff2jpg.o $(REQ:=.o) ff2pam: ff2pam.o $(REQ:=.o) ff2ppm: ff2ppm.o $(REQ:=.o) +ffinfo: ffinfo.o $(REQ:=.o) png2ff.o: png2ff.c config.mk $(HDR) $(REQ:=.h) ff2png.o: ff2png.c config.mk $(HDR) $(REQ:=.h) _AT_@ -31,12 +32,13 @@ jpg2ff.o: jpg2ff.c config.mk $(HDR) $(REQ:=.h) ff2jpg.o: ff2jpg.c config.mk $(HDR) $(REQ:=.h) ff2pam.o: ff2pam.c config.mk $(HDR) $(REQ:=.h) ff2ppm.o: ff2ppm.c config.mk $(HDR) $(REQ:=.h) +ffinfo.o: ffinfo.c config.mk $(HDR) $(REQ:=.h) .o: $(CC) -o $_AT_ $(LDFLAGS) $< $(REQ:=.o) $($*-LDLIBS) .c.o: - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< + $(CC) -c $(CPPFLAGS) $(CFLAGS) -DVERSION='"$(VERSION)"' $< clean: rm -f $(BIN) $(BIN:=.o) $(REQ:=.o) diff --git a/ffinfo.1 b/ffinfo.1 new file mode 100644 index 0000000..adf7382 --- /dev/null +++ b/ffinfo.1 _AT_@ -0,0 +1,47 @@ +.Dd 2018-08-19 +.Dt FFINFO 1 +.Os suckless.org +.Sh NAME +.Nm ffinfo +.Nd print a farbfeld image's dimension +.Sh SYNOPSIS +.Nm +.Op Fl hvw +.Sh DESCRIPTION +.Nm +reads the header of a +.Xr farbfeld 5 +image from stdin, and write information from the header to stdout. +.Pp +In case of an error +.Nm +writes a diagnostic message to stderr. +.Sh OPTIONS +.Bl -tag -width Ds +.It Fl h +Print the image height. +.It Fl v +Print the current version of farbfeld. +.It Fl w +Print the image width. +.El +.Sh EXIT STATUS +.Bl -tag -width Ds +.It 0 +Image processed successfully. +.It 1 +An error occurred. +.El +.Sh EXAMPLES +$ +.Nm +< image.ff +.Pp +$ bunzip2 < image.ff.bz2 | +.Nm +-b 0f0 -q 90 > image.jpg +.Sh SEE ALSO +.Xr bzip2 1 , +.Xr farbfeld 5 +.Sh AUTHORS +.An Hiltjo Posthuma Aq Mt hiltjo_AT_codemadness.org diff --git a/ffinfo.c b/ffinfo.c new file mode 100644 index 0000000..ce088ff --- /dev/null +++ b/ffinfo.c _AT_@ -0,0 +1,45 @@ +#include <stdint.h> + +#include "arg.h" +#include "util.h" + +void +usage(void) +{ + die("usage: %s [-hvw]", argv0); +} + +int +main(int argc, char **argv) +{ + uint32_t w, h; + int width, height; + + width = height = 0; + ARGBEGIN { + case 'w': + width = 1; + break; + case 'h': + height = 1; + break; + case 'v': + puts(VERSION); + return 0; + default: + usage(); + } ARGEND; + if (argc != 0) + usage(); + + ff_read_header(&w, &h); + + if (width) + printf("%d\n", w); + if (height) + printf("%d\n", h); + if (!width && !height) + printf("%d\t%d\n", w, h); + + return 0; +} -- 2.18.0Received on Sun Aug 19 2018 - 18:43:38 CEST
This archive was generated by hypermail 2.3.0 : Sun Aug 19 2018 - 18:48:23 CEST