Page 1 of 2

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

Posted: 2018-02-06T17:21:19-07:00
by ericpa06
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

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

Posted: 2018-02-06T17:30:41-07:00
by fmw42
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.

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

Posted: 2018-02-06T18:27:17-07:00
by ericpa06
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.

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

Posted: 2018-02-06T18:52:13-07:00
by snibgo
Your error message appears then vanishes. Put a "pause" in your script, then copy-paste the error message here.

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

Posted: 2018-02-06T19:36:45-07:00
by ericpa06
Here's the message

Image

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

Posted: 2018-02-06T20:17:49-07:00
by snibgo
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".

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

Posted: 2018-02-06T20:30:36-07:00
by fmw42
Sorry, I should have made it more clear about the filenames for image1 and image2 and result.

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

Posted: 2018-02-06T20:58:55-07:00
by ericpa06
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: ]

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

Posted: 2018-02-06T21:15:30-07:00
by fmw42
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.

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

Posted: 2018-02-06T21:54:35-07:00
by snibgo
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".

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

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

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

Posted: 2018-02-06T22:12:09-07:00
by ericpa06
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

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

Posted: 2018-02-06T22:19:49-07:00
by snibgo
You have one quote. Quotes normally come in pairs.

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

Posted: 2018-02-06T22:23:08-07:00
by ericpa06
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

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

Posted: 2018-02-06T22:28:05-07:00
by ericpa06
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?