Okay, let’s see if I can explain this…

Picture this: on a page (page i) in a document in InDesign is this 2x2 inch rectangle with the applescript label “IMG01” (aka lItemLabel). After placing a .TIF image in the rectangle I want to resize it within the 2x2 inch bounds but in a way NOT allowed via the ‘fit’ command.

To explain, what I want - much like the ‘fit given proportionally’ I want the image to be resized proportionally… just NOT so the longer dimension of the image fits within the 2x2 inch rectangle, so the shorter dimension does. So if I had a 3.5x5 inch photograph I would want to have the 3.5 inch dimension fit the 2 inch rectangle and the 5 inch dimension would be centered and cropped.

```
on sImageResizer(lImagePlacement, lItemLabel, i)
tell application "InDesign CS"
tell active document
tell page i
if lImagePlacement = "" or lImagePlacement = "p" then
fit rectangle lItemLabel given proportionally -- Shrinks the image down proportionally then
fit rectangle lItemLabel given frame to content -- Reduces the size of the rectangle to fit it
else if lImagePlacement = "c" then
set {RTb, RLb, RBb, RRb} to get geometric bounds of rectangle lItemLabel -- Get dimensions of rectangle
select rectangle lItemLabel
set {ITb, ILb, IBb, IRb} to get geometric bounds of graphic 1 of selection -- Get dimensions of Image
set lRectHeight to (RBb - RTb) -- Height of rectangle
set lRectWidth to (RRb - RLb) -- Width of rectangle
set lImageHeight to (IBb - ITb) -- Height of image
set lImageWidth to (IRb - ILb) -- Width of image
--display dialog ("Rectangle dimensions - H:" & lRectHeight & " W:" & lRectWidth & return & "Image dimensions - H:" & lImageHeight & " W:" & lImageWidth)
if lImageHeight > lImageWidth then -- Get the smaller of the two dimensions
set lMultiplier to (lRectWidth / lImageWidth)
else if lImageWidth > lImageHeight then -- Get the smaller of the two dimensions
set lMultiplier to (lRectHeight / lImageHeight)
else if lImageWidth = lImageHeight then -- If the two dimensions are equal
set lMultiplier to (lRectHeight / lImageHeight) -- Either width OR height would have worked in this instance
end if
--display dialog "Multiplier - " & lMultiplier
set IBb to (IBb * lMultiplier) -- Reduce/enlarge lMultiplier %
set IRb to (IRb * lMultiplier) -- Reduce/enlarge lMultiplier %
set geometric bounds of text frame lItemLabel to {ITb, ILb, IBb, IRb} -- Sets the new Image dimensions
fit rectangle lItemLabel given center content -- Center the image cropping the remainder height or width
end if
end tell
end tell
end tell
end sImageResizer
```

Below is the error I get with this iteration of the script. I have tried several versions and gotten several errors, but this one made the most sense.

Any ideas where I need to go from here?