Use ImageMagick. You can either call it directly, or register the DLL and call it via VBA.
Whichever way you do it, this is the command you want to run:
identify -format %Q filename.jpg