Skip to content

Merge two images in Windows from right-click context menu

  1. Download and install ImageMagick.
  2. Go to Windows Explorer and type sendto in the address bar. This will open the following path:

    C:\Users\<username>\AppData\Roaming\Microsoft\Windows\SendTo

    The files here will be available as actions from the Windows “Send to” right-click context menu.
  3. Create a new (text) file in this directory and add the following line:

    magick.exe %1 %2 -resize "x%%[fx:max(u.h,v.h)]" +append -set filename: "COMBINED-%%k" "%%[filename:].jpg"

    This is essentially what will be executed when you right click two images anywhere and select the action.
    %1 and %2 are the two files
    – the resize parameters makes sure the two images line up correctly, from here
    +append means the images will be merged side by side — horizontally — as opposed to vertically
    filename uses %k to pass some random value to the generated new filename. Otherwise it would overwrite already existing files with the same name. By generating something unique this doesn’t happen. The word COMBINED is chosen by me, you can change this to whatever you like.

    This line has extra % this is necessary when you run this script as a batch script. If you want to run it from the commandline by hand, you need to remove the double %% and replace them for single %.
  4. Name this file Merge two images side by side.bat or any name you like as long it ends with .bat, so Windows knows to execute it.
  5. Done!

And the result looks like this. Click image or here.

5 thoughts on “Merge two images in Windows from right-click context menu”

      1. Any success making this work with more than 9 files? My current .bat file is as below. It processes the first 4 lines, but the fifth doesn’t process. I’ve tested it with a single digit in place of the %10 at that works, so it must be the double digit, any workaround?

        magick.exe %1 %2 -resize “x%%[fx:max(u.h,v.h)]” +append -set filename: “%%t-Joined” “%%[filename:].jpg”

        magick.exe %3 %4 -resize “x%%[fx:max(u.h,v.h)]” +append -set filename: “%%t-Joined” “%%[filename:].jpg”

        magick.exe %5 %6 -resize “x%%[fx:max(u.h,v.h)]” +append -set filename: “%%t-Joined” “%%[filename:].jpg”

        magick.exe %7 %8 -resize “x%%[fx:max(u.h,v.h)]” +append -set filename: “%%t-Joined” “%%[filename:].jpg”

        magick.exe %09 %10 -resize “x%%[fx:max(u.h,v.h)]” +append -set filename: “%%t-Joined” “%%[filename:].jpg”

        1. From ChatGPT (https://chat.openai.com/share/ad419f13-0eb3-45f9-b9fd-bac63cf237c0):

          It seems like the issue might be related to how batch files handle command-line arguments. When you use %10, the batch interpreter interprets it as %1 followed by a literal 0, rather than %10. To overcome this limitation, you can enclose your command line arguments in double quotes like `%~10` which will handle double-digit arguments correctly.

          This modification ensures that double-digit arguments are handled correctly.

Leave a Reply

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