0

I have created different uncompressed bitmap images with the same pixel size (2000x2000) and different content (black, red, white and a photograph) expecting the file size in bytes to be exactly the same regardless of the content.

These were the results:

  • wc -c command reporting the same size for each image (12000056 bytes).
  • Hex Editor reporting identical results in size. I also can clearly see the bitmap pixel information for each RGB channel as expected.
  • Mac OSX "Finder" and "Get Info" reporting small differences. (12 106 957, 12 005 274, 12 005 261...)

What could justify these differences? Is this the OS adding some metadata? Something related to the filesystem? Is there any way to know exactly what's going on?

5
  • Can't reproduce the error here, and the size should be 12000054 bytes since bmp header is 54 bytes.
    – lex
    Jul 4, 2015 at 21:26
  • Yes, the size is exactly that in bytes... I was planning on posting pictures but I can't due to my reputation, or lack thereof, on superuser.
    – Joyce
    Jul 4, 2015 at 23:09
  • Actually the size I get is 12000056. After checking the HEX it indeed has the 54 bytes of header but all of the files seem to have an extra 2 bytes (00 00) at the end. Regardless of that they all have the same size. The only discrepancy is on the "Get Info".
    – Joyce
    Jul 4, 2015 at 23:22
  • It might be that the files have resource forks or something similar that Finder's including in the size. Try using ls -l@ on the files to see their extended attributes and their sizes. Jul 5, 2015 at 5:06
  • Yes, it is the resource forks. I will read more about that. Thank you. Could you rewrite that comment as an answer so I can accept it?
    – Joyce
    Jul 5, 2015 at 8:29

1 Answer 1

0

Looks like it was due to the files having resource forks as well as data forks. Resource forks are an old (mostly obsolete) feature of OS X's filesystem that can store additional data about the file. The Finder will consider a resource fork as part of the file's size, but most unix-style tools don't even know they exist, and hence won't show them as part of the file's size. Here's a listing of an old document I have:

$ wc -c About\ iMac\ Firmware\ Update 
    2710 About iMac Firmware Update
$ ls -l@ About\ iMac\ Firmware\ Update
-rwx---r-x@ 1 gordon  staff  2710 Sep 14  2001 About iMac Firmware Update
    com.apple.FinderInfo      32
    com.apple.ResourceFork  17759

The Finder's Info window shows its size as 20,269 bytes (= 2,710 in the data fork + 17,759 in the resource fork).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .