Page 1 of 1

Imagemagick

Posted: Thu Mar 09, 2023 4:07 pm
by Krzysztof Mycek
Hi
I have a question about Imagemagick in Switch. I have a 2 file (tiff). I need to make the one file from two file by imagemagick like:

1.tiff 2.tiff -channel-fx "| gray=>alpha" -define tiff:alpha=unspecified "%1" "%2"

But how I can use the Switch flow to send 2 file to Imagemagic??

Re: Imagemagick

Posted: Thu Mar 09, 2023 9:38 pm
by jan_suhr
You can try to send them to one folder each on disk and then you add the full path to each file.

With the app "Execute command friend" you can construct a .bat or .sh file that you send to Execute command. This file would have the complete execution command in it but it will also allow you to use variables from Switch for the file names of each TIFF-file.

https://www.enfocus.com/en/appstore/pro ... and-friend

Re: Imagemagick

Posted: Fri Mar 10, 2023 8:08 am
by freddyp
You obviously have to replace 1.tiff and 2.tiff by variables. As the two files have to hit ImageMagick at the same time, you first have to assemble the two files into a job folder using "Assemble job". You can then access the first file with the variable [Job.NestedName:Index="2",Space="trim"] and the second one with index 3. Index 1 is for the name of the job folder which in this case is not important.

You also have to concatenate the path to the job folder with the variables mentioned above using a slash. In "Execute Command Friend" you will have to use [Job.Path] for that, in "Execute command" it is the variable %1 that points to the job path. So you will use [Job.Path]/[Job.NestedName:Index="2",Space="trim"] or %1/[Job.NestedName:Index="2",Space="trim"].

Caution: enclose the concatenated paths in double quotes to avoid problems with spaces in the complete path.

Re: Imagemagick

Posted: Fri Mar 10, 2023 10:33 am
by Krzysztof Mycek
Thank You. I will try it.

Re: Imagemagick

Posted: Fri Mar 10, 2023 11:57 am
by Krzysztof Mycek
hm ... the path is correct but always
Job failed because outcode is nonzero, outcode = [1]

My command is:
%1 /[Job.NestedName:Index="2",Space="trim"] [Job.NestedName:Index="3",Space="trim"]" -channel-fx "| gray=>alpha" -define tiff:alpha=unspecified "%2"

result: %1 /1.tiff 2.tiff" -channel-fx "| gray=>alpha" -define tiff:alpha=unspecified "%2"

Both file are in the folder called "a"

I hate those magical spells to imagemagic ....

Re: Imagemagick

Posted: Fri Mar 10, 2023 12:40 pm
by freddyp
The references to the input files are definitely not correct. There is a space after %1, the path should be enclosed in double quotes and the %1 is missing for the path to the second file. It should be:
"%1/[Job.NestedName:Index="2",Space="trim"]" "%1/[Job.NestedName:Index="3",Space="trim"]" -channel-fx etc.

I did not test this! You may have to be play with the double quotes because as it is here there are double quotes inside double quotes and that does not always go well.

You write "My command is:". Just to make sure: the "Command" is the path to ImageMagick, the rest goes in "Arguments".

Re: Imagemagick

Posted: Fri Mar 10, 2023 1:10 pm
by Krzysztof Mycek
Of course!. Thank You Freddy for You help. That is like always very useful.

Re: Imagemagick

Posted: Fri Mar 10, 2023 1:15 pm
by Krzysztof Mycek
and that is correct with Run Command connector:


/opt/homebrew/Cellar/imagemagick/7.1.0-62/bin/magick %%InputFilePath%%/[Job.NestedName:Index="2",Space="trim"] %%InputFilePath%%/[Job.NestedName:Index="3",Space="trim"] -channel-fx "| gray=>alpha" -define tiff:alpha=unspecified rezultat.tiff


https://www.enfocus.com/en/appstore/product/run-command