# Making an image a specific size (physical AND file)



## Involute (Oct 12, 2008)

I have an application requiring a number of digital images (JPEGs) which are all the same physical AND file size, e.g. 2" x 2" and 54,321 bytes.  Any tips on how I can take existing images and make them conform?  I have some basic facility with Photoshop but I'm by no means an expert.  Maybe make all the images the same physical size in Photoshop, then add text to EXIF to the smallest ones to bring all of them up to the same size as the largest (any limits on how much data can get stuffed into EXIF)?  I don't know.  Thanks.


----------



## Garbz (Oct 18, 2008)

Makes no sense what you're asking. The bytes 54321 are not set as image parameters but by compression quality, and the size 2" x 2" is meaningless without knowing how many dots per inch you have.


----------



## Alex_B (Oct 18, 2008)

what strange application would need exactly the same file size?

and as mentioned, the print size quoted in the file data does not have any meaning. well, you can set it to whatever you want of course using photoshop.

as for the file size, you should contact the person who invented the application and tell him to drop that limitation.


----------



## Involute (Oct 18, 2008)

Sorry for the lack of detail; I was trying to keep the post simple.  I'm thinking of making a variant of a CAPTCHA access control application (to distinguish between a human and a computer) where the user will be presented with several photos and must identify the ones with a certain characteristic (e.g. "check all the pix containing a cat").  Image size, dpi, and file size must be the same for all the pix in the database, otherwise a human could record that data, note the characteristics (essentially a fingerprint) for the cat photos, and store them in a program intended to spoof the system.


----------



## Garbz (Oct 18, 2008)

Not directly related to the image problem but: If you insert a human element into the CAPTCHA then it is essentially broken as you must send the data to the computer and the human is capable of breaking it. This has implications you mention since fingerprinting works regardless if it's the same file size or not. Even random data is quite easily fingerprinted. That is why so many programs rely on generating new random data each time, and it is often their generation code is reverse engineered to break it.

The only way to really prevent fingerprinting is to use a continuous stream of new data such as what is done by reCAPTCHA, the company who digitises old prints, and who only ever show the same picture to a couple of clients before replacing it.

Even without the human element, and continuous random generation I don't think it would work. Even KittenAuth which displayed pictures of cats and other animals and asks you to click the cat was broken, and broken by definition means only a small percentage hit rate since all attacks are essentially automated, so even a 1% success rate and the spammer essentially has control again.

As for producing identical file sizes you effectively can not do this with JPEG. You'd need to look at a small TIFF or something else which has 100% control over the file size. As soon as you apply compression the image file changes depending on the complexity and details within the image. An algorithm to work around that would be either arcane or rather processor intensive.

DPI again couldn't be what you are after since this is something which ONLY ever relates to printing of the picture. If anything it's file size and resolution that you're after. And as per above if you don't use compression you're guaranteed the same file size for each image which has the same resolution. AND to do that you could record an action in photoshop of you opening the image, resizing the image, and saving it as an uncompressed TIFF or BMP.


----------

