Thanks for coming to, the world's #1 resource for all things InDesign!

Exchange or Swap Two Images with this Free InDesign Script

You have two images that you want to exchange or swap*. The first question is do you want to exchange the frames themselves, or do you want the frames to stay where they are and just move each image into the other’s frame?

I talked about swapping two objects in this article. So now let’s talk about how to exchange the images and leave the frames where they are.

For example, let’s say I’m laying out this page and I decide to swap two images:

how to exchange images

To do this, there’s the slower way (manually) and the fast way (use a free little script). Let me show you the slow, manual way first… alternatively, you can skip this section and get the free script below.

The manual method for swapping two images

First, duplicate the two frames by Option/Alt-dragging them with the Selection tool:

duplicate images

Next double-click one image to select it inside the frame, then cut it to the clipboard. Now select the alternate frame (where you want to put it) and choose Edit > Paste Into… and then do the same with the other image:

exchanging images

You’ll notice that the images are the wrong size and position. So now you can delete the empty frames, select the original frames and choose Object > Fitting > Fill Frame Proportionally. (Or whatever fitting option you desire.)

after fitting images

On the topic of frame fitting

InDesign’s frame fitting options make this process far faster than it would be otherwise. I highly recommend creating and applying an object style that applies frame fitting to the graphic frames before you use the manual or scripted method of swapping images.

object style with frame fitting

However, did you know that sometimes InDesign assigns frame fitting to your frames even if you don’t ask it to? If you place an image by clicking, you typically will not get any frame fitting options applied to it. But if you click-and-drag with the Place cursor (to scale the image), InDesign automatically applies Fitting > Fit Content Proportionally to the frame! Isn’t that interesting?

The fast free script method

OK, now the moment you’ve been waiting for: How can I swap images quickly, with a script? You can download the script here. (And, if you need help installing scripts, read this.)

To run the script, simply select the two frames and double-click the script (or use Quick Apply to run it).

History: Back in 2009, Gerald Singelmann wrote a “startup script” that would do this with a menu command. However, apparently it’s buggy in later versions of InDesign, so an anonymous poster extracted the important code from it. I simply took that code, saved it into a .jsx file and… it seems to work great!

So thanks to Gerald, and thank you to whomever grabbed that helpful bit of code!

* Isn’t “swap” a strange word? It turns out that the etymology of the word is “to strike,” as in clapping hands in a bargain—just as you might shake hands when you say “I’ll give you this for that.”

David Blatner

David Blatner

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at are among the most watched InDesign training in the world. You can find more about David at
David Blatner

Latest posts by David Blatner (see all)

  • - November 30, -0001
Related Articles

9 Comments on “Exchange or Swap Two Images with this Free InDesign Script

  1. Gerald’s script is a “must have” on any machine I work on, and I’ve featured it on one of my “must-have” videos on Youtube.
    Gerald’s startup script can be called upon by selecting the two images and right clicking to show the contextual menu, and then select the option “swap images” at the bottom of the contextual menu, whereas the newer script has to be run from the javascript panel or quick-apply panel.
    It’s worth noting that the newer script hasn’t fixed or replaced the old script; it’s only lines 44-59 of Gerald’s original script that have been copied and made into its own script purely for the purpose of swapping images, whereas Gerald’s script also allows objects to be swapped as well.
    That said, I’ve never experienced any issues running Gerald’s script and continue to run it on ID CC 2018 running on my High Sierra Mac. The error may have been to a particular version ID, but I can safely say it works fine on my machine.

    • I can second Colin. Gerald’s original script works perfectly over all versions of InDesign up to CC2018 (Mac OS 10.12.6) and I never faced an error with it. Where does the info come from, that Gerald’s script is buggy in newer versions of ID?

  2. I support Colin: the script does work for me beautifully in InDesign CC 2018 on Windows 10.
    David, what do you mean by the term ‘buggy’? Do you get an error message on start up?
    I am aware of the bug in the Russian version of InDesign CC 2015 (maybe it’s also present in later versions, but I haven’t tested it yet) which doesn’t understand locale independent strings in scripts (they are used, in particular, to reference menu items). In this version the script produced the ‘object is invalid’ error on line 38 while trying to add a separation line in the context menu.
    Alternatively, we can swap images from Bridge using this script. Make sure to select an image with the selection tool (black arrow) in InDesign — the contents selection tool (white arrow) won’t work.

  3. Thanks a lot for sharing!

    Unfortunately it won’t work in my case:
    ID CC 2018 (Version 13.0.1, german) Mac OS High Sierra (Version 10.13.3)

    Running the script it shows me: Java Script Error; No. 30477; invalid parameter.

    Could be, that the script stops in ligne 12?

    • Hello, Kristin,

      I had the problem too. You can easily solve it by moving the jsx file to the Scripts Panel folder of Indesign, e.g. under Samples/Javascript.

      Start InDesign, show window utilities/scripts (Ctrl+Alt+F11). Select two images, double click the script.

  4. I wish this worked for me. I did all the steps and when it’s installed in the scripts folder, and hovered over in the scripts panel in InDesign, it tells me “This file is not executable by any supported script language.” I can’t even move it out of the user folder. I can only delete it.

Leave a Reply

Your email address will not be published. Required fields are marked *