Small Application C

#include
#include
int main(int argc, char *argv[]) {
FILE *fp = {0};
gdImagePtr img;
int x = 0;
int y = 0;
int width = 0;
int height = 0;
if(argc != 2) {
fprintf(stderr, "Usage: gixel image.png\n");
return 1;
}
fp = fopen(argv[1], "rb");
if(fp == NULL) {
fprintf(stderr, "Error - fopen(%s)\n", argv[1]);
return 1;
}
img = gdImageCreateFromPng(fp);
fclose(fp);
width = gdImageSX(img);
height = gdImageSY(img);
for(x = 0; x < width; x++)
for(y = 0; y < height; y++)
printf("%d,%d:%X\n", x, y, gdImageGetPixel(img, x, y));
gdImageDestroy(img);
return 0;
}