I'm attempting to ascertain the maximum file size possible of a jpg to detect when someone has hidden additional data (viruses etc) within it.

Assuming that you have an image that is 640x480 with no metadata (no camera make, gps data etc), what is the maximum size that that file can be? Is there an formula for calculating this with other jpg dimensions?

closed as too localized by Alan Gilbertson Sep 22 '12 at 20:46

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    you might have a better time asking in StackOverflow or Math.StackExchange. Present the algorithm and the dimensions you're asking about and see if anyone might be able to steer you in the right direction. – Ryan Sep 22 '12 at 13:57
  • 1
    I can't see this question relates to design. As it gives no context, it doesn't appear that it would be useful to others. – Alan Gilbertson Sep 22 '12 at 20:46
  • I've added context, which may make this question more useful to others – hellocatfood Oct 28 '12 at 20:21

Assuming that no compression has been applied to the file, there are 307,200 pixels, which is a 0.3MP. Handy look up table

If each pixel contains 24 bits of information for Red green and blue, then

  1. 307,200 * 24 = 7,372,800 bits of information
  2. Divide by the 8 bits to become a byte value
  3. 7,372,800 / 8 = 921,600 bytes (Or 0.9 Mb)

I hope my Saturday night reasoning is intact, but the good mathematicians and computer scientists may well correct me.

  • Thanks, that sounds right. I'll mark it as correct if it is – hellocatfood Sep 22 '12 at 19:53
  • That is the raw data size, not much to do with JPEG which is a lossy compressed format – e100 Sep 23 '12 at 18:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.