summaryrefslogtreecommitdiffstats
path: root/lisiblepng-bin/src
diff options
context:
space:
mode:
Diffstat (limited to 'lisiblepng-bin/src')
-rw-r--r--lisiblepng-bin/src/main.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/lisiblepng-bin/src/main.c b/lisiblepng-bin/src/main.c
new file mode 100644
index 0000000..7979326
--- /dev/null
+++ b/lisiblepng-bin/src/main.c
@@ -0,0 +1,33 @@
+#include <errno.h>
+#include <lisiblepng.h>
+#include <log.h>
+#include <string.h>
+
+int main(int argc, char **argv) {
+ if (argc != 2) {
+ LOG0("Usage: lisiblepng <png filepath>");
+ return 1;
+ }
+
+ const char *png_filepath = argv[1];
+ FILE *png_file = fopen(png_filepath, "r");
+ if (!png_file) {
+ const char *error_message = strerror(errno);
+ LOGN("Couldn't open PNG file: %s", error_message);
+ goto err;
+ }
+
+ Png *png = lis_Png_parse(png_file);
+ lis_Png_dump_ppm(png);
+ lis_Png_destroy(png);
+
+ if (fclose(png_file) != 0) {
+ const char *error_message = strerror(errno);
+ LOGN("Couldn't close PNG file: %s", error_message);
+ goto err;
+ }
+
+ return 0;
+err:
+ return 1;
+}
Go back to lisible.xyz