]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add read and write a image file
authorBastian Dehn <hhaalo@arcor.de>
Sun, 4 Feb 2024 18:42:56 +0000 (19:42 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 4 Feb 2024 18:42:56 +0000 (19:42 +0100)
src/kds_s2000w_image_converter.c

index 9ef396c4e51cb142c59a5fa675aedb7a12852439..7607b8d44f08926b5946818ea25180504e171240 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <string.h>
 #include <magick/MagickCore.h>
 #include "kds_s2000w_image_converter.h"
 
@@ -14,5 +15,31 @@ void kds_s2000w_convert_terminate()
 
 void kds_s2000w_convert_jpg_to_pnm(const char* filename)
 {
-       printf("open image file: %s\n", filename);
+       printf("open input_image file: %s\n", filename);
+
+       ExceptionInfo* exception = NULL;
+       Image* input_image = NULL;
+       Image* output_image = NULL;
+       ImageInfo* image_info = NULL;
+
+       exception = AcquireExceptionInfo();
+       image_info = CloneImageInfo(NULL);
+       strcpy(image_info->filename, filename);
+       input_image = ReadImage(image_info, exception);
+
+       if (exception->severity != UndefinedException)
+               CatchException(exception);
+       if (input_image == NULL)
+               exit(1);
+
+       DestroyImageInfo(image_info);
+       DestroyExceptionInfo(exception);
+       exception = AcquireExceptionInfo();
+       image_info = CloneImageInfo(NULL);
+       strcpy(image_info->filename, "output_test.jpg");
+       WriteImages(image_info, input_image, "output.jpg", exception);
+
+       DestroyImageInfo(image_info);
+       DestroyImage(input_image);
+       DestroyExceptionInfo(exception);
 }
\ No newline at end of file