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.

Comments

6 responses to “Merge two images in Windows from right-click context menu”

  1. Ali Khan Avatar

    Works great. Years ive been searching for this. You are awsome, whoever you are !!

  2. hadrian Avatar
    hadrian

    how to more than 2 files, like 24 images?

    1. Jan van den Berg Avatar

      Play around with the parameters %1 and %2 means first and second image. Try adding %3, %4 etc.

      1. Jon Avatar
        Jon

        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. Jan van den Berg Avatar

          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.

  3. alee Avatar
    alee

    How can I make the option appear under main options rather than ‘SendTo’?

Leave a Reply

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