1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4
5 #include "evas_options.h"
6
7 #include "evas_common_private.h"
8 #include "evas_private.h"
9
10
11 int
evas_common_save_image_to_file(RGBA_Image * im,const char * file,const char * key,int quality,int compress,const char * encoding)12 evas_common_save_image_to_file(RGBA_Image *im, const char *file, const char *key,
13 int quality, int compress, const char *encoding)
14 {
15 Evas_Image_Save_Func *evas_image_save_func = NULL;
16 char *p;
17 char *saver = NULL;
18
19 p = strrchr(file, '.');
20 if (p)
21 {
22 p++;
23
24 if (!strcasecmp(p, "png"))
25 saver = "png";
26 if ((!strcasecmp(p, "jpg")) || (!strcasecmp(p, "jpeg")) ||
27 (!strcasecmp(p, "jfif")))
28 saver = "jpeg";
29 if ((!strcasecmp(p, "eet")) || (!strcasecmp(p, "edj")) ||
30 (!strcasecmp(p, "eap")))
31 saver = "eet";
32 if (!strcasecmp(p, "webp"))
33 saver = "webp";
34 if (!strcasecmp(p, "tgv"))
35 saver = "tgv";
36 if (!strcasecmp(p, "avif"))
37 saver = "avif";
38 }
39
40 if (saver)
41 {
42 Evas_Module *em;
43
44 em = evas_module_find_type(EVAS_MODULE_TYPE_IMAGE_SAVER, saver);
45 if (em)
46 {
47 evas_module_use(em);
48 if (evas_module_load(em))
49 {
50 evas_image_save_func = em->functions;
51 return evas_image_save_func->image_save(im, file, key, quality,
52 compress, encoding);
53 }
54 }
55 }
56 return 0;
57 }
58