"test-png" tool to find PNGs that cause warnings
New tool, "test-png", which exercises libpng library on a set of PNG image files, allowing us to find those which cause Tux Paint (via SDL_image, in turn via libpng) to report back warnings to STDERR. h/t Tim Dickson, per https://sourceforge.net/p/tuxpaint/bugs/252/
This commit is contained in:
parent
844db56ab9
commit
06fafcb6d6
4 changed files with 112 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -16,3 +16,4 @@ TuxPaint.dmg
|
||||||
src/po/POTFILES.in
|
src/po/POTFILES.in
|
||||||
src/tuxpaint.desktop
|
src/tuxpaint.desktop
|
||||||
src/org.tuxpaint.Tuxpaint.appdata.xml
|
src/org.tuxpaint.Tuxpaint.appdata.xml
|
||||||
|
test-png
|
||||||
|
|
|
||||||
10
Makefile
10
Makefile
|
|
@ -4,7 +4,7 @@
|
||||||
# Various contributors (see AUTHORS.txt)
|
# Various contributors (see AUTHORS.txt)
|
||||||
# http://www.tuxpaint.org/
|
# http://www.tuxpaint.org/
|
||||||
|
|
||||||
# June 14, 2002 - June 29, 2022
|
# June 14, 2002 - July 3, 2022
|
||||||
|
|
||||||
|
|
||||||
# The version number, for release:
|
# The version number, for release:
|
||||||
|
|
@ -315,6 +315,9 @@ NOSVGFLAG:=$(if $(SVG_LIB),,-DNOSVG$(warning No SVG for you!))
|
||||||
OLDSVGFLAG:=$(if $(filter -lsvg-cairo,$(SVG_LIB)),-DOLD_SVG,)
|
OLDSVGFLAG:=$(if $(filter -lsvg-cairo,$(SVG_LIB)),-DOLD_SVG,)
|
||||||
|
|
||||||
|
|
||||||
|
PNG_CFLAGS:=$(shell $(PKG_CONFIG) libpng --cflags)
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(hack),1)
|
ifeq ($(hack),1)
|
||||||
hack:
|
hack:
|
||||||
@echo 'SDL_PANGO_LIB is' $(SDL_PANGO_LIB)
|
@echo 'SDL_PANGO_LIB is' $(SDL_PANGO_LIB)
|
||||||
|
|
@ -715,6 +718,7 @@ clean:
|
||||||
@-rm -f TuxPaint.dmg temp.dmg; rm -rf magic/*.dSYM Resources
|
@-rm -f TuxPaint.dmg temp.dmg; rm -rf magic/*.dSYM Resources
|
||||||
@-rm -f dlllist a.exe
|
@-rm -f dlllist a.exe
|
||||||
@-rm -f win32/Preprocessed.iss win32/tuxpaint-*.zip win32/tuxpaint-*.exe
|
@-rm -f win32/Preprocessed.iss win32/tuxpaint-*.zip win32/tuxpaint-*.exe
|
||||||
|
@-rm -f test-png
|
||||||
@echo
|
@echo
|
||||||
|
|
||||||
# "make uninstall" should remove the various parts from their
|
# "make uninstall" should remove the various parts from their
|
||||||
|
|
@ -1400,3 +1404,7 @@ $(MAGIC_SO): magic/%.$(SO_TYPE): magic/src/%.c
|
||||||
|
|
||||||
.PHONY: magic-plugins
|
.PHONY: magic-plugins
|
||||||
magic-plugins: src/tp_magic_api.h $(MAGIC_SO)
|
magic-plugins: src/tp_magic_api.h $(MAGIC_SO)
|
||||||
|
|
||||||
|
test-png: src/test-png.c
|
||||||
|
$(CC) $(PNG_CFLAGS) src/test-png.c -o test-png $(PNG)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,12 @@ http://www.tuxpaint.org/
|
||||||
Terrence Sheflin <terrence.sheflin@gmail.com>
|
Terrence Sheflin <terrence.sheflin@gmail.com>
|
||||||
Pere Pujal i Carabantes <perepujal@gmail.com>
|
Pere Pujal i Carabantes <perepujal@gmail.com>
|
||||||
|
|
||||||
|
* New tool, "test-png", which exercises libpng library on
|
||||||
|
a set of PNG image files, allowing us to find those which
|
||||||
|
cause Tux Paint (via SDL_image, in turn via libpng) to
|
||||||
|
report back warnings to STDERR.
|
||||||
|
h/t Tim Dickson, per https://sourceforge.net/p/tuxpaint/bugs/252/
|
||||||
|
|
||||||
* Documentation updates:
|
* Documentation updates:
|
||||||
---------------------
|
---------------------
|
||||||
* Update macOS build instructions for SDL2.0.
|
* Update macOS build instructions for SDL2.0.
|
||||||
|
|
|
||||||
96
src/test-png.c
Normal file
96
src/test-png.c
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
test-png.c
|
||||||
|
|
||||||
|
A tiny test program that opens a PNG file using libpng
|
||||||
|
library. If any warnings come back, this can help us tell
|
||||||
|
when any images include oddities that would cause Tux Paint
|
||||||
|
to echo warnings (via SDL_image->libpng) to stderr when it
|
||||||
|
goes to load them.
|
||||||
|
|
||||||
|
See https://sourceforge.net/p/tuxpaint/bugs/252/
|
||||||
|
|
||||||
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
|
||||||
|
(Based loosely on example code by Yoshimasa Niwa, https://gist.github.com/niw,
|
||||||
|
located at https://gist.github.com/niw/5963798, which itself was based on
|
||||||
|
code by Guillaume Cottenceau found at http://zarb.org/~gc/html/libpng.html)
|
||||||
|
|
||||||
|
2022-07-03 - 2022-07-03
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <png.h>
|
||||||
|
|
||||||
|
int main(int argc, char * argv[]) {
|
||||||
|
int i;
|
||||||
|
FILE * fi;
|
||||||
|
png_structp png;
|
||||||
|
png_infop info;
|
||||||
|
|
||||||
|
/* Usage output */
|
||||||
|
if (argc == 1 || strcmp(argv[1], "--help") == 0) {
|
||||||
|
fprintf(stderr, "Usage: %s file.png [file.png ...]\n", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Redirect stderr to stdout, so libpng's warnings can
|
||||||
|
be in the same stream as our's (where we report each
|
||||||
|
file's filename); allows more easily dumping to a file,
|
||||||
|
piping through `| less`, etc. */
|
||||||
|
dup2(STDOUT_FILENO, STDERR_FILENO);
|
||||||
|
|
||||||
|
|
||||||
|
/* Open each PNG image!... */
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
printf("%5d ------------------------------------------------------------------\n", i);
|
||||||
|
printf("%s\n", argv[i]);
|
||||||
|
|
||||||
|
/* Open the file */
|
||||||
|
fi = fopen(argv[i], "rb");
|
||||||
|
if (fi == NULL) {
|
||||||
|
printf("Cannot open\n");
|
||||||
|
} else {
|
||||||
|
/* Prepare PNG library stuff... */
|
||||||
|
png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
|
if (!png) {
|
||||||
|
fprintf(stderr, "Cannot png_create_read_struct()!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
info = png_create_info_struct(png);
|
||||||
|
if (!info) {
|
||||||
|
fprintf(stderr, "Cannot png_create_info_struct()!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setjmp(png_jmpbuf(png))) {
|
||||||
|
fprintf(stderr, "Cannot setjmp(png_jmpbuf(png)))!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the PNG's info */
|
||||||
|
png_init_io(png, fi);
|
||||||
|
png_read_info(png, info);
|
||||||
|
|
||||||
|
/* *** At this point, libpng would have reported issues *** */
|
||||||
|
|
||||||
|
/* (We could do additional things, like reporting image
|
||||||
|
dimensions, color depth, etc., but I don't see any reason to
|
||||||
|
care right now. -bjk 2022.07.03) */
|
||||||
|
|
||||||
|
/* Close and move on to the next file */
|
||||||
|
png_destroy_read_struct(&png, &info, NULL);
|
||||||
|
fclose(fi);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue