summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-09-22 21:41:54 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-09-22 21:41:54 (GMT)
commit3d403c230e1b9cb6b99d9603106ae1dce2c989d2 (patch)
tree4fe0614759b6e8ed60716f4ee03356f1233c00d2
parentd256e96a21a3400512dc60fbd70517c4e59d56d6 (diff)
unlink image right after reading it
-rw-r--r--src/klokdisplay.c25
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);