How to get accurate local file dimensions

Im making a PNG loader but I cant seem to find a way to get the dimensions of a PNG. I found this but It doesnt seem to work and just prints overly large numbers. How would I get the dimensions without it being like this: 12333,0?

I just found out that the module I was using has the width and height but it doesnt return it so I modified the module.