"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/gd_filename.c" between
libgd-2.3.1.tar.gz and libgd-2.3.2.tar.gz

About: LibGD is a library for the dynamic creation of images by programmers (PNG, JPEG, GIF, WebP, XPM, BMP support).

gd_filename.c  (libgd-2.3.1):gd_filename.c  (libgd-2.3.2)
skipping to change at line 39 skipping to change at line 39
static void BGD_STDCALL writewbmp(gdImagePtr im, FILE *out) { static void BGD_STDCALL writewbmp(gdImagePtr im, FILE *out) {
int fg = gdImageColorClosest(im, 0, 0, 0); int fg = gdImageColorClosest(im, 0, 0, 0);
gdImageWBMP(im, fg, out); gdImageWBMP(im, fg, out);
}/* writejpeg*/ }/* writejpeg*/
static void BGD_STDCALL writebmp(gdImagePtr im, FILE *out) { static void BGD_STDCALL writebmp(gdImagePtr im, FILE *out) {
gdImageBmp(im, out, GD_TRUE); gdImageBmp(im, out, GD_TRUE);
}/* writejpeg*/ }/* writejpeg*/
enum FType {UNKNOWN, PNG, JPG, GIF, TIFF, GD, GD2, WEBP}; static const struct FileType {
static struct FileType {
const char *ext; const char *ext;
ReadFn reader; ReadFn reader;
WriteFn writer; WriteFn writer;
LoadFn loader; LoadFn loader;
} Types[] = { } Types[] = {
{".gif", gdImageCreateFromGif, gdImageGif, NULL}, {".gif", gdImageCreateFromGif, gdImageGif, NULL},
{".gd", gdImageCreateFromGd, gdImageGd, NULL}, {".gd", gdImageCreateFromGd, gdImageGd, NULL},
{".wbmp", gdImageCreateFromWBMP, writewbmp, NULL}, {".wbmp", gdImageCreateFromWBMP, writewbmp, NULL},
{".bmp", gdImageCreateFromBmp, writebmp, NULL}, {".bmp", gdImageCreateFromBmp, writebmp, NULL},
{".xbm", gdImageCreateFromXbm, NULL, NULL}, {".xbm", gdImageCreateFromXbm, NULL, NULL},
{".tga", gdImageCreateFromTga, NULL, NULL}, {".tga", gdImageCreateFromTga, NULL, NULL},
#ifdef HAVE_LIBAVIF
{".avif", gdImageCreateFromAvif, gdImageAvif, NULL},
#endif
#ifdef HAVE_LIBPNG #ifdef HAVE_LIBPNG
{".png", gdImageCreateFromPng, gdImagePng, NULL}, {".png", gdImageCreateFromPng, gdImagePng, NULL},
#endif #endif
#ifdef HAVE_LIBJPEG #ifdef HAVE_LIBJPEG
{".jpg", gdImageCreateFromJpeg, writejpeg, NULL}, {".jpg", gdImageCreateFromJpeg, writejpeg, NULL},
{".jpeg", gdImageCreateFromJpeg, writejpeg, NULL}, {".jpeg", gdImageCreateFromJpeg, writejpeg, NULL},
#endif #endif
#ifdef HAVE_LIBHEIF
{".heic", gdImageCreateFromHeif, gdImageHeif, NULL},
{".heix", gdImageCreateFromHeif, NULL, NULL},
#endif
#ifdef HAVE_LIBTIFF #ifdef HAVE_LIBTIFF
{".tiff", gdImageCreateFromTiff, gdImageTiff, NULL}, {".tiff", gdImageCreateFromTiff, gdImageTiff, NULL},
{".tif" , gdImageCreateFromTiff, gdImageTiff, NULL}, {".tif" , gdImageCreateFromTiff, gdImageTiff, NULL},
#endif #endif
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
{".gd2", gdImageCreateFromGd2, writegd2, NULL}, {".gd2", gdImageCreateFromGd2, writegd2, NULL},
#endif #endif
#ifdef HAVE_LIBWEBP #ifdef HAVE_LIBWEBP
{".webp", gdImageCreateFromWebp, gdImageWebp, NULL}, {".webp", gdImageCreateFromWebp, gdImageWebp, NULL},
#endif #endif
#ifdef HAVE_LIBXPM #ifdef HAVE_LIBXPM
{".xpm", NULL, NULL, gdImageCreateFromXpm}, {".xpm", NULL, NULL, gdImageCreateFromXpm},
#endif #endif
{NULL, NULL, NULL} {NULL, NULL, NULL}
}; };
struct FileType * static const struct FileType *
ftype(const char *filename) { ftype(const char *filename) {
int n; int n;
char *ext; char *ext;
/* Find the file extension (i.e. the last period in the string. */ /* Find the file extension (i.e. the last period in the string. */
ext = strrchr(filename, '.'); ext = strrchr(filename, '.');
if (!ext) return NULL; if (!ext) return NULL;
for (n = 0; Types[n].ext; n++) { for (n = 0; Types[n].ext; n++) {
if (strcasecmp(ext, Types[n].ext) == 0) { if (strcasecmp(ext, Types[n].ext) == 0) {
skipping to change at line 129 skipping to change at line 137
following extensions are supported: following extensions are supported:
- .gif - .gif
- .gd, .gd2 - .gd, .gd2
- .wbmp - .wbmp
- .bmp - .bmp
- .xbm - .xbm
- .tga - .tga
- .png - .png
- .jpg, .jpeg - .jpg, .jpeg
- .heif, .heix
- .avif
- .tiff, .tif - .tiff, .tif
- .webp - .webp
- .xpm - .xpm
Names are parsed case-insenstively. Names are parsed case-insenstively.
Parameters: Parameters:
filename - Filename with tested extension. filename - Filename with tested extension.
writing - Flag: true tests if writing works writing - Flag: true tests if writing works
Returns: Returns:
GD_TRUE (1) if the file type is supported, GD_FALSE (0) if not. GD_TRUE (1) if the file type is supported, GD_FALSE (0) if not.
*/ */
BGD_DECLARE(int) BGD_DECLARE(int)
gdSupportsFileType(const char *filename, int writing) { gdSupportsFileType(const char *filename, int writing) {
struct FileType *entry = ftype(filename); const struct FileType *entry = ftype(filename);
return !!entry && (!writing || !!entry->writer); return !!entry && (!writing || !!entry->writer);
}/* gdSupportsFileType*/ }/* gdSupportsFileType*/
/* /*
Function: gdImageCreateFromFile Function: gdImageCreateFromFile
Read an image file of any supported. Read an image file of any supported.
Given the path to a file, <gdImageCreateFromFile> will open the Given the path to a file, <gdImageCreateFromFile> will open the
file, read its contents with the appropriate _gdImageCreateFrom*_ file, read its contents with the appropriate _gdImageCreateFrom*_
skipping to change at line 180 skipping to change at line 190
filename - the input file name filename - the input file name
Returns: Returns:
A pointer to the new image or NULL if an error occurred. A pointer to the new image or NULL if an error occurred.
*/ */
BGD_DECLARE(gdImagePtr) BGD_DECLARE(gdImagePtr)
gdImageCreateFromFile(const char *filename) { gdImageCreateFromFile(const char *filename) {
struct FileType *entry = ftype(filename); const struct FileType *entry = ftype(filename);
FILE *fh; FILE *fh;
gdImagePtr result; gdImagePtr result;
if (!entry) return NULL; if (!entry) return NULL;
if (entry->loader) return entry->loader((char *)filename); if (entry->loader) return entry->loader((char *)filename);
if (!entry->reader) return NULL; if (!entry->reader) return NULL;
fh = fopen(filename, "rb"); fh = fopen(filename, "rb");
if (!fh) return NULL; if (!fh) return NULL;
skipping to change at line 234 skipping to change at line 244
filename - The path to the file to which the image is saved. filename - The path to the file to which the image is saved.
Returns: Returns:
GD_FALSE (0) if an error was detected, GD_TRUE (1) if not. GD_FALSE (0) if an error was detected, GD_TRUE (1) if not.
*/ */
BGD_DECLARE(int) BGD_DECLARE(int)
gdImageFile(gdImagePtr im, const char *filename) { gdImageFile(gdImagePtr im, const char *filename) {
struct FileType *entry = ftype(filename); const struct FileType *entry = ftype(filename);
FILE *fh; FILE *fh;
if (!entry || !entry->writer) return GD_FALSE; if (!entry || !entry->writer) return GD_FALSE;
fh = fopen(filename, "wb"); fh = fopen(filename, "wb");
if (!fh) return GD_FALSE; if (!fh) return GD_FALSE;
entry->writer(im, fh); entry->writer(im, fh);
fclose(fh); fclose(fh);
 End of changes. 8 change blocks. 
6 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)