diff options
author | Christian Pointner <equinox@spreadspace.org> | 2015-09-22 23:41:54 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2015-09-22 23:41:54 +0200 |
commit | 3d403c230e1b9cb6b99d9603106ae1dce2c989d2 (patch) | |
tree | 4fe0614759b6e8ed60716f4ee03356f1233c00d2 | |
parent | inital copy as a copy of the original display command of imagemagick (diff) |
unlink image right after reading it
-rw-r--r-- | src/klokdisplay.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/klokdisplay.c b/src/klokdisplay.c index ed0b757..ec6025c 100644 --- a/src/klokdisplay.c +++ b/src/klokdisplay.c @@ -20,23 +20,32 @@ */ #include <stdio.h> +#include <unistd.h> #include <wand/MagickWand.h> int main(int argc, char **argv) { - ExceptionInfo *exception; - ImageInfo *image_info; - MagickBooleanType status; + if(argc < 2) { + fprintf(stderr, "Usage: klokdisplay <file>\n"); + exit(1); + } + + MagickWand *wand = NULL; + MagickBooleanType status = MagickFalse; MagickCoreGenesis(*argv, MagickTrue); - exception = AcquireExceptionInfo(); - image_info = AcquireImageInfo(); - status = MagickCommandGenesis(image_info, DisplayImageCommand, argc, argv, (char **)NULL, exception); + wand = NewMagickWand(); + if(wand) { + status = MagickReadImage(wand, argv[1]); + unlink(argv[1]); + if(status != MagickFalse) { + status = MagickDisplayImage(wand, NULL); + } + wand = DestroyMagickWand(wand); + } - image_info = DestroyImageInfo(image_info); - exception = DestroyExceptionInfo(exception); MagickCoreTerminus(); return(status != MagickFalse ? 0 : 1); |