Imagemagick

Post Reply
Krzysztof Mycek
Member
Posts: 30
Joined: Tue Mar 03, 2020 11:28 am

Imagemagick

Post 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??
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Imagemagick

Post 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
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: Imagemagick

Post 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.
Krzysztof Mycek
Member
Posts: 30
Joined: Tue Mar 03, 2020 11:28 am

Re: Imagemagick

Post by Krzysztof Mycek »

Thank You. I will try it.
Krzysztof Mycek
Member
Posts: 30
Joined: Tue Mar 03, 2020 11:28 am

Re: Imagemagick

Post 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 ....
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: Imagemagick

Post 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".
Krzysztof Mycek
Member
Posts: 30
Joined: Tue Mar 03, 2020 11:28 am

Re: Imagemagick

Post by Krzysztof Mycek »

Of course!. Thank You Freddy for You help. That is like always very useful.
Krzysztof Mycek
Member
Posts: 30
Joined: Tue Mar 03, 2020 11:28 am

Re: Imagemagick

Post 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
Post Reply