You have an image or another graphic that you want to place in a a frame with fixed dimensions and you want to resize the image using an uniform scale which will leave an even margin inside the frame around the image, that is what this script will enable you to achieve with a single click.
For example, you have a photo that you want to print in the center of a sheet that you will cut to the dimensions of a picture frame you bought to place it into, and for aesthetic concern you wish the photo to be centered and surrounded with an even unprinted paper margin like for the framing of a watercolour painting, but you want to preserve the integrity of the photo without deforming nor cropping it.
Geometrically speaking, for a graphic frame and a graphic item of given proportions,
- there is one and only one uniform scale that will enable you to fit the image to the width or height of the frame cropping it in the other direction, that is what the command Fitting > Fill Frame Proportionally is intended for,
- there is one and only one uniform scale that will enable you to fit the image to the width or height of the frame keeping margins in the other direction, that is what the command Fitting > Fit Content Proportionally is intended for,
- but there is also, at best, one uniform scale, or sometimes none, that will enable you to center the image into the frame leaving a perfectly even margin around the 4 sides, for what there is no built-in InDesign command, so from now this script is here to meet this need.
Of course no uniform scale will enable you to fit this third way a portrait-format graphic in a landscape or square-format frame or the contrary. In the particular case of a square image in a square frame, any scale will suit and the script will be useless, in the particular case where the graphic frame and the image have exactly the same proportions the only appropriate scale will be the proportional resizing of the image to the exact dimensions of the frame without any margin. In the other cases, either the image shape is slightly (or very) more elongated (in width or height) than the frame and the script will enable you to get an uniform margin (the longer is the image shape, the greater this margin will be and will give a result similar to this style of framing), in the case where the frame shape is the most elongated, it is impossible to get an uniform margin around the image and the algorithm will return a negative margin (not a bug but the harsh reality of the geometrical laws ruling our universe), that is an uniform cropping, which is generally not what you would have wished except in the particular case of an image including unwanted margins as extra white or black pixels on the edges.
To get an uniform margin all around the image you need to use this script after setting the reference point locator (in the Transform or Control panel) to the center. Setting the reference point in one of the four corners will give you an uniform margin on the two opposite sides, setting the reference point in the middle of one of the four edges will will give you an uniform margin on the three other sides. If you deformed the image using a non-uniform scale before launching the script it will assume that the deformation is intentional and will preserve it during the resizing, if not the case you will first have to cancel the deformation.