A lil’ script to scale images for the web using Exif.
Requires exiftool.
% node exif-resolution img.jpg 400x300
No matter what img.jpg’s actual pixel dimensions are, this will set its Exif metadata in such a way that browsers (well, some browsers) will give it an intrinsic size of 400-px-wide and 300-px-tall.
% node exif-resolution img.jpg 2x
You can also just give the script an image density. For example, if img.jpg is 800 × 600, this command is equivalent to the previous one. Both will cause browsers to give the image a .naturalWidth of 400, a .naturalHeight of 300, and an intrinsic density of 2x.