20main (
int argc,
char **argv)
25 int useStdinStdout = 0;
38 if (argc < 2 || !
strcmp (argv[1],
"--help"))
45 if (
strcmp (
"-", argv[argc - 1]) == 0)
52 in =
fopen (argv[argc - 1],
"rb");
57 "Error: can't open file %s.\n", argv[argc - 1]);
67 "Error: %s is not a valid PNG file.\n", argv[argc - 1]);
71 for (i = 1; (i < (argc - 1)); i++)
74 if (!
strcmp (argv[i],
"--help"))
80 else if (!
strcmp (argv[i],
"-i"))
85 "Error: -i specified without y or n.\n");
89 if (!
strcmp (argv[i + 1],
"y"))
94 else if (!
strcmp (argv[i + 1],
"n"))
102 "Error: -i specified without y or n.\n");
110 else if (!
strcmp (argv[i],
"-t"))
117 "Error: -t specified without a color table index.\n");
121 if (!
strcmp (argv[i + 1],
"none"))
129 index = atoi (argv[i + 1]);
136 else if (!
strcmp (argv[i],
"-l"))
143 printf (
"Index Red Green Blue Alpha\n");
147 printf (
"%d %d %d %d %d\n",
157 printf (
"Truecolor image, no palette entries to list.\n");
161 else if (!
strcmp (argv[i],
"-d"))
165 printf (
"Width: %d Height: %d Colors: %d\n",
171 printf (
"First 100%% transparent index: %d\n", t);
176 printf (
"First 100%% transparent index: none\n");
180 printf (
"Interlaced: yes\n");
184 printf (
"Interlaced: no\n");
188 else if (!
strcmp(argv[i],
"-a"))
190 int maxx, maxy, x, y, alpha, pix, nalpha = 0;
195 printf(
"alpha channel information:\n");
198 for (y = 0; y < maxy; y++) {
199 for (x = 0; x < maxx; x++) {
217 printf(
"NOT a true color image\n");
219 printf(
"%d alpha channels\n", nalpha);
224 fprintf (stderr,
"Unknown argument: %s\n", argv[i]);
233 "Usage: webpng [-i y|n ] [-l] [-t index|none ] [-d] pngname.png\n"
235 " -i [y|n] Turns on/off interlace\n"
236 " -l Prints the table of color indexes\n"
237 " -t [index] Set the transparent color to the specified index (0-255 or \"none\")\n"
238 " -d Reports the dimensions and other characteristics of the image.\n"
239 " -a Prints all alpha channels that are not 100%% opaque.\n"
241 "If you specify '-' as the input file, stdin/stdout will be used input/output.\n"
255 snprintf (outFn,
sizeof(outFn),
"webpng.tmp%d", getpid ());
261 "Unable to write to %s -- exiting\n", outFn);
275 if (
rename (outFn, argv[argc - 1]) != 0)
unlink(string $filename, $context=null)
fprintf($stream, string $format, mixed ... $values)
rename(string $from, string $to, $context=null)
printf(string $format, mixed ... $values)
fopen(string $filename, string $mode, bool $use_include_path=false, $context=null)
#define gdImageBlue(im, c)
#define gdTrueColorGetBlue(c)
#define gdTrueColorGetGreen(c)
#define gdTrueColorGetAlpha(c)
#define gdImageGetTransparent(im)
void gdImagePng(gdImagePtr im, FILE *out)
#define gdTrueColorGetRed(c)
#define gdImageColorsTotal(im)
#define gdImageGreen(im, c)
#define gdImageGetInterlaced(im)
#define gdImageAlpha(im, c)
gdImagePtr gdImageCreateFromPng(FILE *fd)
#define gdImageRed(im, c)
int gdImageGetPixel(gdImagePtr im, int x, int y)
void gdImageDestroy(gdImagePtr im)
void gdImageInterlace(gdImagePtr im, int interlaceArg)
void gdImageColorTransparent(gdImagePtr im, int color)
exit(string|int $status=0)
strcmp(string $string1, string $string2)