--- a/cimg.cc	2014-05-25 02:41:58.000000000 -0500
+++ b/cimg.cc	2014-05-25 02:42:31.000000000 -0500
@@ -94,11 +94,11 @@
       ct == PNG_COLOR_TYPE_GRAY_ALPHA)
     png_set_gray_to_rgb(pngp);

-  alloc(pngp->width,pngp->height);
+  alloc(png_get_image_width(pngp, infp),png_get_image_height(pngp, infp));
   if (!ok) { fclose(f); return; }
   ok = 0;

-  for(i=0;i<pngp->height;i++) {
+  for(i=0;i<png_get_image_height(pngp, infp);i++) {
     png_read_row(pngp, (png_bytep) (&data[i*rowlen]), NULL);
   }