forked from old/legacy-imlib2
loaders: Use common function to print error messages
Also: - gif loader: Add error about corrupt frame sequence - tiff loader: Drop OOM message - Not done elsewhere - webp loader: Drop messages about quality tag outside [0-100] - Not done elsewhere
This commit is contained in:
parent
11cef49cef
commit
8a36ae6d8d
|
@ -156,7 +156,10 @@ _load(ImlibImage * im, int load_data)
|
||||||
while (data)
|
while (data)
|
||||||
{
|
{
|
||||||
if (DGifGetCodeNext(gif, &data) == GIF_ERROR)
|
if (DGifGetCodeNext(gif, &data) == GIF_ERROR)
|
||||||
goto done;
|
{
|
||||||
|
E("Corrupt image frame\n");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
DL(" DGifGetCodeNext: size=%d data=%p\n", size, data);
|
DL(" DGifGetCodeNext: size=%d data=%p\n", size, data);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <id3tag.h>
|
#include <id3tag.h>
|
||||||
|
|
||||||
|
#define DBG_PFX "LDR-id3"
|
||||||
|
|
||||||
#define USE_TAGS 0
|
#define USE_TAGS 0
|
||||||
|
|
||||||
static const char *const _formats[] = { "mp3" };
|
static const char *const _formats[] = { "mp3" };
|
||||||
|
@ -56,14 +58,13 @@ context_create(const char *filename, FILE * f)
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
fprintf(stderr, "Unable to open tagged file %s: %s\n",
|
E("Unable to open tagged file %s: %m\n", filename);
|
||||||
filename, strerror(errno));
|
|
||||||
goto fail_free;
|
goto fail_free;
|
||||||
}
|
}
|
||||||
tag = id3_file_tag(file);
|
tag = id3_file_tag(file);
|
||||||
if (!tag)
|
if (!tag)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unable to find ID3v2 tags in file %s\n", filename);
|
E("Unable to find ID3v2 tags in file %s\n", filename);
|
||||||
id3_file_close(file);
|
id3_file_close(file);
|
||||||
goto fail_free;
|
goto fail_free;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,7 @@ context_create(const char *filename, FILE * f)
|
||||||
/* Paranoid! this can occur only if there are INT_MAX contexts :) */
|
/* Paranoid! this can occur only if there are INT_MAX contexts :) */
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Too many open ID3 contexts\n");
|
E("Too many open ID3 contexts\n");
|
||||||
goto fail_close;
|
goto fail_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +151,7 @@ context_get(int id)
|
||||||
}
|
}
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "No context by handle %d found\n", id);
|
E("No context by handle %d found\n", id);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +303,7 @@ get_options(lopt * opt, const ImlibImage * im)
|
||||||
(index == 0 && id3_tag_get_numframes(ctx->tag) < 1))
|
(index == 0 && id3_tag_get_numframes(ctx->tag) < 1))
|
||||||
{
|
{
|
||||||
if (index)
|
if (index)
|
||||||
fprintf(stderr, "No picture frame # %d found\n", index);
|
E("No picture frame # %d found\n", index);
|
||||||
context_delref(ctx);
|
context_delref(ctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +329,7 @@ extract_pic(struct id3_frame *frame, int dest)
|
||||||
data = id3_field_getbinarydata(field, &length);
|
data = id3_field_getbinarydata(field, &length);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No image data found for frame\n");
|
E("No image data found for frame\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
while (length > 0)
|
while (length > 0)
|
||||||
|
@ -364,7 +365,7 @@ get_loader(lopt * opt, ImlibLoader ** loader)
|
||||||
data = (char const *)id3_field_getlatin1(field);
|
data = (char const *)id3_field_getlatin1(field);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No mime type data found for image frame\n");
|
E("No mime type data found for image frame\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (strncasecmp(data, "image/", 6))
|
if (strncasecmp(data, "image/", 6))
|
||||||
|
@ -374,14 +375,13 @@ get_loader(lopt * opt, ImlibLoader ** loader)
|
||||||
*loader = NULL;
|
*loader = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fprintf(stderr,
|
E("Picture frame with unknown mime-type \'%s\' found\n", data);
|
||||||
"Picture frame with unknown mime-type \'%s\' found\n", data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
strncpy(ext + 1, data + 6, EXT_LEN);
|
strncpy(ext + 1, data + 6, EXT_LEN);
|
||||||
if (!(*loader = __imlib_FindBestLoader(ext, NULL, 0)))
|
if (!(*loader = __imlib_FindBestLoader(ext, NULL, 0)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No loader found for extension %s\n", ext);
|
E("No loader found for extension %s\n", ext);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -518,7 +518,7 @@ _load(ImlibImage * im, int load_data)
|
||||||
|
|
||||||
if ((dest = mkstemp(tmp)) < 0)
|
if ((dest = mkstemp(tmp)) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unable to create a temporary file\n");
|
E("Unable to create a temporary file\n");
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ _load(ImlibImage * im, int load_data)
|
||||||
data = (char const *)id3_field_getbinarydata(field, &length);
|
data = (char const *)id3_field_getbinarydata(field, &length);
|
||||||
if (!data || !length)
|
if (!data || !length)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No link image URL present\n");
|
E("No link image URL present\n");
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
url = (char *)malloc((length + 1) * sizeof(char));
|
url = (char *)malloc((length + 1) * sizeof(char));
|
||||||
|
@ -560,7 +560,7 @@ _load(ImlibImage * im, int load_data)
|
||||||
file = (strncmp(url, "file://", 7) ? url : url + 7);
|
file = (strncmp(url, "file://", 7) ? url : url + 7);
|
||||||
if (!(loader = __imlib_FindBestLoader(file, NULL, 0)))
|
if (!(loader = __imlib_FindBestLoader(file, NULL, 0)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No loader found for file %s\n", file);
|
E("No loader found for file %s\n", file);
|
||||||
free(url);
|
free(url);
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
@ -588,8 +588,7 @@ _load(ImlibImage * im, int load_data)
|
||||||
fprintf(stderr, "Tags for file %s:\n", im->file);
|
fprintf(stderr, "Tags for file %s:\n", im->file);
|
||||||
while (cur)
|
while (cur)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\t%s: (%d) %s\n", cur->key,
|
E("\t%s: (%d) %s\n", cur->key, cur->val, (char *)cur->data);
|
||||||
cur->val, (char *)cur->data);
|
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -378,7 +378,7 @@ _load(ImlibImage * im, int load_data)
|
||||||
|
|
||||||
if (!rgba_image.rgba.put.any)
|
if (!rgba_image.rgba.put.any)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "imlib2-tiffloader: No put function");
|
E("No put function\n");
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,10 +415,7 @@ _load(ImlibImage * im, int load_data)
|
||||||
|
|
||||||
rast = _TIFFmalloc(sizeof(uint32_t) * im->w * im->h);
|
rast = _TIFFmalloc(sizeof(uint32_t) * im->w * im->h);
|
||||||
if (!rast)
|
if (!rast)
|
||||||
{
|
QUIT_WITH_RC(LOAD_OOM);
|
||||||
fprintf(stderr, "imlib2-tiffloader: Out of memory\n");
|
|
||||||
QUIT_WITH_RC(LOAD_OOM);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rgba_image.rgba.isContig)
|
if (rgba_image.rgba.isContig)
|
||||||
{
|
{
|
||||||
|
|
|
@ -133,20 +133,9 @@ _save(ImlibImage * im)
|
||||||
{
|
{
|
||||||
quality = quality_tag->val;
|
quality = quality_tag->val;
|
||||||
if (quality < 0)
|
if (quality < 0)
|
||||||
{
|
quality = 0;
|
||||||
fprintf(stderr,
|
else if (quality > 100)
|
||||||
"Warning: 'quality' setting %f too low for WebP, using 0\n",
|
quality = 100;
|
||||||
quality);
|
|
||||||
quality = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (quality > 100)
|
|
||||||
{
|
|
||||||
fprintf(stderr,
|
|
||||||
"Warning, 'quality' setting %f too high for WebP, using 100\n",
|
|
||||||
quality);
|
|
||||||
quality = 100;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
encoded_size = WebPEncodeBGRA((uint8_t *) im->data, im->w, im->h,
|
encoded_size = WebPEncodeBGRA((uint8_t *) im->data, im->w, im->h,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "Imlib2_Loader.h"
|
#include "Imlib2_Loader.h"
|
||||||
|
|
||||||
|
#define DBG_PFX "LDR-xpm"
|
||||||
|
|
||||||
static const char *const _formats[] = { "xpm" };
|
static const char *const _formats[] = { "xpm" };
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
@ -230,21 +232,17 @@ _load(ImlibImage * im, int load_data)
|
||||||
sscanf(line, "%i %i %i %i", &w, &h, &ncolors, &cpp);
|
sscanf(line, "%i %i %i %i", &w, &h, &ncolors, &cpp);
|
||||||
if ((ncolors > 32766) || (ncolors < 1))
|
if ((ncolors > 32766) || (ncolors < 1))
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
E("XPM files with colors > 32766 or < 1 not supported\n");
|
||||||
"IMLIB ERROR: XPM files with colors > 32766 or < 1 not supported\n");
|
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
if ((cpp > 5) || (cpp < 1))
|
if ((cpp > 5) || (cpp < 1))
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
E("XPM files with characters per pixel > 5 or < 1 not supported\n");
|
||||||
"IMLIB ERROR: XPM files with characters per pixel > 5 or < 1 not supported\n");
|
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
if (!IMAGE_DIMENSIONS_OK(w, h))
|
if (!IMAGE_DIMENSIONS_OK(w, h))
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
E("Invalid image dimension: %dx%d\n", w, h);
|
||||||
"IMLIB ERROR: Invalid image dimension: %dx%d\n",
|
|
||||||
w, h);
|
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
im->w = w;
|
im->w = w;
|
||||||
|
|
Loading…
Reference in New Issue