From f576dfb703eb17999c11b36b0f5e7360784f0a49 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sun, 25 Nov 2001 03:46:24 +0000 Subject: [PATCH] img_export.. for peoel to list possible exportable imaged from dbs and export them to png's SVN revision: 5730 --- tools/Makefile.am | 7 +++- tools/e_img_export.c | 77 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 tools/e_img_export.c diff --git a/tools/Makefile.am b/tools/Makefile.am index 67d6ce35a..27fa8ba45 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -4,13 +4,18 @@ INCLUDES = \ -I$(top_srcdir)/intl \ @evas_cflags@ @edb_cflags@ @ebits_cflags@ @ecore_cflags@ @efsd_cflags@ @ferite_cflags@ -bin_PROGRAMS = e_img_import e_setup +bin_PROGRAMS = e_img_import e_img_export e_setup e_img_import_SOURCES = \ e_img_import.c e_img_import_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @ferite_libs@ -lm -lc $(INTLLIBS) +e_img_export_SOURCES = \ +e_img_export.c + +e_img_export_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @ferite_libs@ -lm -lc $(INTLLIBS) + e_setup_SOURCES = \ e_setup.c diff --git a/tools/e_img_export.c b/tools/e_img_export.c new file mode 100644 index 000000000..3d55dde35 --- /dev/null +++ b/tools/e_img_export.c @@ -0,0 +1,77 @@ +#include +#include +#include +#include +#include + +static int sort_compare(const void *v1, const void *v2); + +static int +sort_compare(const void *v1, const void *v2) +{ + return strcmp(*(char **)v1, *(char **)v2); +} + +int main(int argc, char **argv) +{ + Imlib_Image im; + + if (argc == 1) + { + printf("usage:\n\t%s src.db:/key/in/db dest_image\n", argv[0]); + printf("usage:\n\t%s src.db\n", argv[0]); + exit(-1); + } + if (argc == 2) + { + E_DB_File *db; + char **keys; + int keys_num; + int i; + + db = e_db_open_read(argv[1]); + if (!db) + { + printf("Cannot load db:\n"); + printf(" %s\n", argv[1]); + exit(0); + } + keys_num = 0; + keys = e_db_dump_key_list(argv[1], &keys_num); + qsort(keys, keys_num, sizeof(char *), sort_compare); + printf("Possible images in db file:\n"); + printf(" %s\n", argv[1]); + printf("Possible entries: %i\n", keys_num); + printf(" filtering out known non-image entries...\n"); + printf("---\n"); + for (i = 0; i < keys_num; i++) + { + char *t; + char *type; + + type = e_db_type_get(db, keys[i]); + if ( + (!type) || + ( + (!(!strcmp(type, "int"))) && + (!(!strcmp(type, "float"))) && + (!(!strcmp(type, "str"))) + ) + ) + printf("%s:%s\n", argv[1], keys[i]); + if (type) free(type); + } + e_db_close(db); + e_db_flush(); + exit(0); + } + im = imlib_load_image(argv[1]); + if (im) + { + imlib_context_set_image(im); + imlib_image_attach_data_value("compression", NULL, 9, NULL); + imlib_image_set_format("png"); + imlib_save_image(argv[2]); + } + return 0; +}