Prueba Si PNGwriter Abre Tus PNGs De Manera Satisfactoria




A partir de la versión 0.5.4, PNGwriter ahora puede abrir PNGs de una mayor variedad de bit depths (ve la descripción de readfromfile() en el Manual). Hay todavía algunas variantes que no producirán error, pero las cuales no serán leidas correctamente, ya sea presentando errores visuales notorios, o porque tienen leves alteraciones de tonalidad.

. Este ejemplo muestra en tablas todos los archivos incluidos en la colección PngSuite de archivos PNG de prueba antes y después de ser leídos por PNGwriter, el color type y el bit depth, tal y como los interpreta PNGwriter, y cualquier error escrito a la consola.

Para ver precisamente qué tipos de imagenes hicieron que PNGwriter se comportara de manera inesperada, por favor ve la referencia de PngSuite.

Después de la larga lista de imágenes encontrarás el el código fuente del programa que generó estas imágenes.


Imágenes que son leídas sin problemas.

Antes
Después
Nombre de archivo, color type, bit depth
según PNGwriter
Errores reportados
basi0g01.png, Color Type: 2, Bit Depth: 8  
basi0g04.png, Color Type: 2, Bit Depth: 8  
basi0g08.png, Color Type: 2, Bit Depth: 8  
basi0g16.png, Color Type: 2, Bit Depth: 16  
basi2c08.png, Color Type: 2, Bit Depth: 8  
basi2c16.png, Color Type: 2, Bit Depth: 16  
basi3p01.png, Color Type: 2, Bit Depth: 8  
basi3p02.png, Color Type: 2, Bit Depth: 8  
basi3p04.png, Color Type: 2, Bit Depth: 8  
basi3p08.png, Color Type: 2, Bit Depth: 8  
basn0g01.png, Color Type: 2, Bit Depth: 8  
basn0g04.png, Color Type: 2, Bit Depth: 8  
basn0g08.png, Color Type: 2, Bit Depth: 8  
basn0g16.png, Color Type: 2, Bit Depth: 16  
basn2c08.png, Color Type: 2, Bit Depth: 8  
basn2c16.png, Color Type: 2, Bit Depth: 16  
basn3p01.png, Color Type: 2, Bit Depth: 8  
basn3p02.png, Color Type: 2, Bit Depth: 8  
basn3p04.png, Color Type: 2, Bit Depth: 8  
basn3p08.png, Color Type: 2, Bit Depth: 8  
cdfn2c08.png, Color Type: 2, Bit Depth: 8  
cdhn2c08.png, Color Type: 2, Bit Depth: 8  
cdsn2c08.png, Color Type: 2, Bit Depth: 8  
cdun2c08.png, Color Type: 2, Bit Depth: 8  
ch1n3p04.png, Color Type: 2, Bit Depth: 8  
ch2n3p08.png, Color Type: 2, Bit Depth: 8  
cm0n0g04.png, Color Type: 2, Bit Depth: 8  
cm7n0g04.png, Color Type: 2, Bit Depth: 8  
cm9n0g04.png, Color Type: 2, Bit Depth: 8  
cs3n2c16.png, Color Type: 2, Bit Depth: 16  
cs3n3p08.png, Color Type: 2, Bit Depth: 8  
cs5n2c08.png, Color Type: 2, Bit Depth: 8  
cs5n3p08.png, Color Type: 2, Bit Depth: 8  
cs8n2c08.png, Color Type: 2, Bit Depth: 8  
cs8n3p08.png, Color Type: 2, Bit Depth: 8  
ct0n0g04.png, Color Type: 2, Bit Depth: 8  
ct1n0g04.png, Color Type: 2, Bit Depth: 8  
ctzn0g04.png, Color Type: 2, Bit Depth: 8  
g03n0g16.png, Color Type: 2, Bit Depth: 16  
g03n2c08.png, Color Type: 2, Bit Depth: 8  
g03n3p04.png, Color Type: 2, Bit Depth: 8  
g04n0g16.png, Color Type: 2, Bit Depth: 16  
g04n2c08.png, Color Type: 2, Bit Depth: 8  
g04n3p04.png, Color Type: 2, Bit Depth: 8  
g05n0g16.png, Color Type: 2, Bit Depth: 16  
g05n2c08.png, Color Type: 2, Bit Depth: 8  
g05n3p04.png, Color Type: 2, Bit Depth: 8  
g07n0g16.png, Color Type: 2, Bit Depth: 16  
g07n2c08.png, Color Type: 2, Bit Depth: 8  
g07n3p04.png, Color Type: 2, Bit Depth: 8  
g10n0g16.png, Color Type: 2, Bit Depth: 16  
g10n2c08.png, Color Type: 2, Bit Depth: 8  
g10n3p04.png, Color Type: 2, Bit Depth: 8  
g25n0g16.png, Color Type: 2, Bit Depth: 16  
g25n2c08.png, Color Type: 2, Bit Depth: 8  
g25n3p04.png, Color Type: 2, Bit Depth: 8  
oi1n0g16.png, Color Type: 2, Bit Depth: 16  
oi1n2c16.png, Color Type: 2, Bit Depth: 16  
oi2n0g16.png, Color Type: 2, Bit Depth: 16  
oi2n2c16.png, Color Type: 2, Bit Depth: 16  
oi4n0g16.png, Color Type: 2, Bit Depth: 16  
oi4n2c16.png, Color Type: 2, Bit Depth: 16  
oi9n0g16.png, Color Type: 2, Bit Depth: 16  
oi9n2c16.png, Color Type: 2, Bit Depth: 16  
pp0n2c16.png, Color Type: 2, Bit Depth: 16  
ps1n0g08.png, Color Type: 2, Bit Depth: 8  
ps1n2c16.png, Color Type: 2, Bit Depth: 16  
ps2n0g08.png, Color Type: 2, Bit Depth: 8  
ps2n2c16.png, Color Type: 2, Bit Depth: 16  
s01i3p01.png, Color Type: 2, Bit Depth: 8  
s01n3p01.png, Color Type: 2, Bit Depth: 8  
s02i3p01.png, Color Type: 2, Bit Depth: 8  
s02n3p01.png, Color Type: 2, Bit Depth: 8  
s03i3p01.png, Color Type: 2, Bit Depth: 8  
s03n3p01.png, Color Type: 2, Bit Depth: 8  
s04i3p01.png, Color Type: 2, Bit Depth: 8  
s04n3p01.png, Color Type: 2, Bit Depth: 8  
s05i3p02.png, Color Type: 2, Bit Depth: 8  
s05n3p02.png, Color Type: 2, Bit Depth: 8  
s06i3p02.png, Color Type: 2, Bit Depth: 8  
s06n3p02.png, Color Type: 2, Bit Depth: 8  
s07i3p02.png, Color Type: 2, Bit Depth: 8  
s07n3p02.png, Color Type: 2, Bit Depth: 8  
s08i3p02.png, Color Type: 2, Bit Depth: 8  
s08n3p02.png, Color Type: 2, Bit Depth: 8  
s09i3p02.png, Color Type: 2, Bit Depth: 8  
s09n3p02.png, Color Type: 2, Bit Depth: 8  
s32i3p04.png, Color Type: 2, Bit Depth: 8  
s32n3p04.png, Color Type: 2, Bit Depth: 8  
s33i3p04.png, Color Type: 2, Bit Depth: 8  
s33n3p04.png, Color Type: 2, Bit Depth: 8  
s34i3p04.png, Color Type: 2, Bit Depth: 8  
s34n3p04.png, Color Type: 2, Bit Depth: 8  
s35i3p04.png, Color Type: 2, Bit Depth: 8  
s35n3p04.png, Color Type: 2, Bit Depth: 8  
s36i3p04.png, Color Type: 2, Bit Depth: 8  
s36n3p04.png, Color Type: 2, Bit Depth: 8  
s37i3p04.png, Color Type: 2, Bit Depth: 8  
s37n3p04.png, Color Type: 2, Bit Depth: 8  
s38i3p04.png, Color Type: 2, Bit Depth: 8  
s38n3p04.png, Color Type: 2, Bit Depth: 8  
s39i3p04.png, Color Type: 2, Bit Depth: 8  
s39n3p04.png, Color Type: 2, Bit Depth: 8  
s40i3p04.png, Color Type: 2, Bit Depth: 8  
s40n3p04.png, Color Type: 2, Bit Depth: 8  
tp0n1g08.png, Color Type: 2, Bit Depth: 8  
tp0n2c08.png, Color Type: 2, Bit Depth: 8  
tp0n3p08.png, Color Type: 2, Bit Depth: 8  




Imágenes con problemas serios: Aparte de las imágenes corruptas (la serie x en PngSuite), todas las imágenes que no son leídas correctamente con PNGwriter son aquellos que tienen un transparency chunk (tp0n1g08.png, tp0n2c08.png y tp0n3p08.png, los cuales son leídos perfectamente, son imágenes de referencia sin transparencia). De la referencia PngSuite:

3.5     Transparency (and background) test files
------------------------------------------------

        tp0n1g08    -   not transparent for reference (logo on gray)
        tbbn1g04    -   transparent, black background chunk
        tbwn1g16    -   transparent, white background chunk
        tp0n2c08    -   not transparent for reference (logo on gray)
        tbrn2c08    -   transparent, red background chunk
        tbgn2c16    -   transparent, green background chunk
        tbbn2c16    -   transparent, blue background chunk
        tp0n3p08    -   not transparent for reference (logo on gray)
        tp1n3p08    -   transparent, but no background chunk
        tbbn3p08    -   transparent, black background chunk
        tbgn3p08    -   transparent, light-gray background chunk
        tbwn3p08    -   transparent, white background chunk
        tbyn3p08    -   transparent, yellow background chunk

3.12     Corrupted files
-----------------------

        x00n0g01    -   empty 0x0 grayscale file
        xcrn0g04    -   added cr bytes
        xlfn0g04    -   added lf bytes
        


Antes
Después
Nombre de archivo, color type, bit depth
según PNGwriter
Errores reportados
tbbn1g04.png, Color Type: 6, Bit Depth: 8 PNGwriter::readfromfile() - WARNING **: Input file is of unsupported type (bad color_type). Output will be unpredictable.
tbbn2c16.png, Color Type: 2, Bit Depth: 16  
tbbn3p08.png, Color Type: 6, Bit Depth: 8 PNGwriter::readfromfile() - WARNING **: Input file is of unsupported type (bad color_type). Output will be unpredictable.
tbgn2c16.png, Color Type: 2, Bit Depth: 16  
tbgn3p08.png, Color Type: 6, Bit Depth: 8 PNGwriter::readfromfile() - WARNING **: Input file is of unsupported type (bad color_type). Output will be unpredictable.
tbrn2c08.png, Color Type: 2, Bit Depth: 8  
tbwn1g16.png, Color Type: 6, Bit Depth: 16 PNGwriter::readfromfile() - WARNING **: Input file is of unsupported type (bad color_type). Output will be unpredictable.
tbwn3p08.png, Color Type: 6, Bit Depth: 8 PNGwriter::readfromfile() - WARNING **: Input file is of unsupported type (bad color_type). Output will be unpredictable.
tbyn3p08.png, Color Type: 6, Bit Depth: 8 PNGwriter::readfromfile() - WARNING **: Input file is of unsupported type (bad color_type). Output will be unpredictable.
tp1n3p08.png, Color Type: 6, Bit Depth: 8 PNGwriter::readfromfile() - WARNING **: Input file is of unsupported type (bad color_type). Output will be unpredictable.
x00n0g01.png, Color Type: 2, Bit Depth: 16 PNGwriter::read_png_info - ERROR **: This file may be a corrupted PNG file. (setjmp(*png_ptr)->jmpbf) failed).
PNGwriter::readfromfile - ERROR **: Error opening file x00n0g01.png. read_png_info() failed.
libpng error: Image width or height is zero in IHDR
xcrn0g04.png, Color Type: 2, Bit Depth: 16 PNGwriter::readfromfile - ERROR **: Error opening file xcrn0g04.png. read_png_info() failed.
PNGwriter::read_png_info - ERROR **: This file may be a corrupted PNG file. (setjmp(*png_ptr)->jmpbf) failed).
libpng error: PNG file corrupted by ASCII conversion
xlfn0g04.png, Color Type: 2, Bit Depth: 16 PNGwriter::read_png_info - ERROR **: This file may be a corrupted PNG file. (setjmp(*png_ptr)->jmpbf) failed). libpng error: PNG file corrupted by ASCII conversion.
PNGwriter::readfromfile - ERROR **: Error opening file xlfn0g04.png. read_png_info() failed.




Images that render with slight tone issues:

Antes
Después
Nombre de archivo, color type, bit depth
según PNGwriter
Errores reportados
basi0g02.png, Color Type: 2, Bit Depth: 8  
basn0g02.png, Color Type: 2, Bit Depth: 8  
ccwn2c08.png, Color Type: 2, Bit Depth: 8  
ccwn3p08.png, Color Type: 2, Bit Depth: 8  
f00n0g08.png, Color Type: 2, Bit Depth: 8  
f00n2c08.png, Color Type: 2, Bit Depth: 8  
f01n0g08.png, Color Type: 2, Bit Depth: 8  
f01n2c08.png, Color Type: 2, Bit Depth: 8  
f02n0g08.png, Color Type: 2, Bit Depth: 8  
f02n2c08.png, Color Type: 2, Bit Depth: 8  
f03n0g08.png, Color Type: 2, Bit Depth: 8  
f03n2c08.png, Color Type: 2, Bit Depth: 8  
f04n0g08.png, Color Type: 2, Bit Depth: 8  
f04n2c08.png, Color Type: 2, Bit Depth: 8  
z00n2c08.png, Color Type: 2, Bit Depth: 8  
z03n2c08.png, Color Type: 2, Bit Depth: 8  
z06n2c08.png, Color Type: 2, Bit Depth: 8  
z09n2c08.png, Color Type: 2, Bit Depth: 8  




Imágenes cuya información de transparencia (alpha channel) se desecha:

Antes
Después
Nombre de archivo, color type, bit depth
según PNGwriter
Errores reportados
basi4a08.png, Color Type: 2, Bit Depth: 8  
basi4a16.png, Color Type: 2, Bit Depth: 16  
basi6a08.png, Color Type: 2, Bit Depth: 8  
basi6a16.png, Color Type: 2, Bit Depth: 16  
basn4a08.png, Color Type: 2, Bit Depth: 8  
basn4a16.png, Color Type: 2, Bit Depth: 16  
basn6a08.png, Color Type: 2, Bit Depth: 8  
basn6a16.png, Color Type: 2, Bit Depth: 16  
bgai4a08.png, Color Type: 2, Bit Depth: 8  
bgai4a16.png, Color Type: 2, Bit Depth: 16  
bgan6a08.png, Color Type: 2, Bit Depth: 8  
bgan6a16.png, Color Type: 2, Bit Depth: 16  
bgbn4a08.png, Color Type: 2, Bit Depth: 8  
bggn4a16.png, Color Type: 2, Bit Depth: 16  
bgwn6a08.png, Color Type: 2, Bit Depth: 8  
bgyn6a16.png, Color Type: 2, Bit Depth: 16  
pp0n6a08.png, Color Type: 2, Bit Depth: 8  



Lo que sigue es un pequeño programa que abre un archivo PNG y luego lo escribe al disco con un nombre alterado, para que sea fácil buscar archivos que no son leídos correctamente por PNGwriter. También sigue un shellscript, para que puedas automatizar este proceso.

#include <pngwriter.h>
#include <stdlib.h>
#include <string>

#include <iostream>
#include <fstream>
using namespace std;

int main(int argc, char *argv[])
{

	   string filename(argv[1]);
	//filename = (*(argv+1));
	if(argc!=2)
	{

	return 0;
	}
	
	pngwriter image(1, 1, 0, "out.png");

    image.readfromfile(argv[1]);
   
   // Rename the file, add -mod to the basename.
   char * newfilename;

   char fl[1024];
   strcpy(fl, filename.c_str());

   newfilename = strtok (fl, "." );
   strcat(newfilename, "-mod.png" ); 
   image.pngwriter_rename(newfilename);



   std::cout << "File Name: " << argv[1] << ",  Color Type: " << image.getcolortype() << ", Bit Depth: " << image.getbitdepth() << std::endl;

   
   image.close();
	return 0;   
}


Y el shellscript.

#!/bin/bash

for abc in *.png
  do
  base=`basename $abc .png`
  png=${base}.png
  ./readfromfile-test $png
#  echo "Finished " ${base}-mod.jpg
done