Quickly merging 2 select files side by side through windows context menu?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
ericpa06
Posts: 11
Joined: 2018-02-06T17:09:02-07:00
Authentication code: 1152

Quickly merging 2 select files side by side through windows context menu?

Post by ericpa06 » 2018-02-06T17:21:19-07:00

So... I was wanting to create a command to quickly merge two selected images side by side (automatically adjusting their height, if there's any diference), and merging them. For instance, I would select two images in the desktop and merge them. It seems that it's possible to do this using Windows "Send To" and ImageMagick, but I don't know

Please, I don't understand anything about commands and stuff, so go easy about the technical stuff. I'm using Windows 10. Something like this:

[Before]
Image
[Later]
Image

User avatar
fmw42
Posts: 23667
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Quickly merging 2 select files side by side through windows context menu?

Post by fmw42 » 2018-02-06T17:30:41-07:00

What version of ImageMagick?

If using IM 7, then in unix syntax

Code: Select all

magick  image1 image2 -resize "x%[fx:max(u.h, v.h)]" +append result
For Windows, you may need to double the % to %%,. I am not a windows user so I may be wrong about this.



For IM 6, you must calculate the the resize argument separately first and store in a variable.

Code: Select all

ht=`convert image1 image2 -format "%[fx:max(u.h, v.h)]\n" info: | head -n 1`
convert lena.png monet2.jpg -resize "x$ht" +append result
Sorry I do not know the equivalent for Windows syntax.

ericpa06
Posts: 11
Joined: 2018-02-06T17:09:02-07:00
Authentication code: 1152

Re: Quickly merging 2 select files side by side through windows context menu?

Post by ericpa06 » 2018-02-06T18:27:17-07:00

I'm using version 7.0. What should I do with this comandy exactly?

"magick image1 image2 -resize "x%%[fx:max(u.h, v.h)]" +append result"

I tried to creat a bat file with it and put it "Send to", but it doesn't seem to be work. Or at least, it's not working as I imagine, to explain better what I would like to do:

https://i.imgur.com/n1HSPxw.gifv

Thank you.

snibgo
Posts: 10561
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Quickly merging 2 select files side by side through windows context menu?

Post by snibgo » 2018-02-06T18:52:13-07:00

Your error message appears then vanishes. Put a "pause" in your script, then copy-paste the error message here.
snibgo's IM pages: im.snibgo.com

ericpa06
Posts: 11
Joined: 2018-02-06T17:09:02-07:00
Authentication code: 1152

Re: Quickly merging 2 select files side by side through windows context menu?

Post by ericpa06 » 2018-02-06T19:36:45-07:00

Here's the message

Image

snibgo
Posts: 10561
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Quickly merging 2 select files side by side through windows context menu?

Post by snibgo » 2018-02-06T20:17:49-07:00

Where Fred put "image1" and "image2", it needs the filenames of your images. As you are using a BAT file, you can put "%1" and "%2" (with no quotes).

Also, for "result" put an output filename, like "out.png".
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 23667
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Quickly merging 2 select files side by side through windows context menu?

Post by fmw42 » 2018-02-06T20:30:36-07:00

Sorry, I should have made it more clear about the filenames for image1 and image2 and result.

ericpa06
Posts: 11
Joined: 2018-02-06T17:09:02-07:00
Authentication code: 1152

Re: Quickly merging 2 select files side by side through windows context menu?

Post by ericpa06 » 2018-02-06T20:58:55-07:00

Ok, I made the adjustments that you guys said, the script it's now able to recognize the name of the files that I selected, but the following message is appearing:

Image

It's seems that it's a problem with the resize specifications, probably something that I didn't specified.

The current bat file is like this:

magick %1 %2 -resize "x%[fx:max(u.h, v.h)]" + file.png

(Sorry being taking your time :lol: ]

User avatar
fmw42
Posts: 23667
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Quickly merging 2 select files side by side through windows context menu?

Post by fmw42 » 2018-02-06T21:15:30-07:00

I do not know window bat scripting but there is something about doubling % to %%. But I am not sure which ones need doubling. The ones for %1 and %2 or the one for "x%[fx:max(u.h, v.h)]" or neither. But remove the + sign. ImageMagick syntax does not use that.

See https://www.imagemagick.org/Usage/windows/ for syntax differences.

snibgo
Posts: 10561
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Quickly merging 2 select files side by side through windows context menu?

Post by snibgo » 2018-02-06T21:54:35-07:00

In the BAT file, %1 and %2, the "%" symbols have special meanings to the shell interpreter, so they are fine. But we don't want the special meaning for the "%" in "x%%[fx:max(u.h,v.h)]", so double that one.

For "+", you should have "+append".
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 23667
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Quickly merging 2 select files side by side through windows context menu?

Post by fmw42 » 2018-02-06T21:56:23-07:00

snibgo wrote:
2018-02-06T21:54:35-07:00
For "+", you should have "+append".
Good catch. I completely missed that.

ericpa06
Posts: 11
Joined: 2018-02-06T17:09:02-07:00
Authentication code: 1152

Re: Quickly merging 2 select files side by side through windows context menu?

Post by ericpa06 » 2018-02-06T22:12:09-07:00

Ok, we are getting closer. The problem seems be with that "-resize "x%%[fx:max(u.h,v.h)]" part, I tried without it, and it worked like a charm, but it didn't resized the image, of course.

https://i.imgur.com/UEOcktG.png

When I tried with the resize command:

magick %1 %2 -resize "x%%[fx:max(u.h,v.h)] +append file.png

It didn't work, this error appeared, saying "Missing Argument"

https://i.imgur.com/yvhNIP8.png

snibgo
Posts: 10561
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Quickly merging 2 select files side by side through windows context menu?

Post by snibgo » 2018-02-06T22:19:49-07:00

You have one quote. Quotes normally come in pairs.
snibgo's IM pages: im.snibgo.com

ericpa06
Posts: 11
Joined: 2018-02-06T17:09:02-07:00
Authentication code: 1152

Re: Quickly merging 2 select files side by side through windows context menu?

Post by ericpa06 » 2018-02-06T22:23:08-07:00

snibgo wrote:
2018-02-06T22:19:49-07:00
You have one quote. Quotes normally come in pairs.
Ops, silly me :lol:

I just tried and it worked like a charm now! Thank you so much guys, especially for your patience. I was looking for some way to do this function for several months :)

Image

ericpa06
Posts: 11
Joined: 2018-02-06T17:09:02-07:00
Authentication code: 1152

Re: Quickly merging 2 select files side by side through windows context menu?

Post by ericpa06 » 2018-02-06T22:28:05-07:00

Just a little last question, and I promise I stop bothering you guys... what if I wanted to merge two images one above the other and do this same resizing?

Post Reply