an output error with -fx_conformal_maps

I made a Perl script that generates GMIC command line strings (here for Win) like

gmic_string_final = “C:\Program Files\gmic_cli_2.0.2_win64\gmic.exe” -input D:\D-ART\Abstrakt_ART\gmic_input.jpg -fx_conformal_maps 0,1,0,“1/(4*z^2-1)”,1,1,0,0,0,2,0,1,“2000”,“2000” -blur 1.5,1,0 -output D:\D-ART\Abstrakt_ART\CM\CM-1_(4$z^2-1)-2017-06-29-01\CM-1_(4$z^2-1)-2017-06-29-01-0001-01-01.jpg

I just tested this command and got the error:

[gmic]-1./ Output image [0] as jpg file ‘D:\D-ART\Abstrakt_ART\CM\CM-1_(4^2-1)-2017-06-29-01\CM-1_(4^2-1)-2017-06-29-01-0001-01-01.jpg’, with quality 100% (1 image 2000x2000x1x4).
[gmic]-1./ *** Error *** Command ‘-output’: gmic::fopen(): Failed to open file ‘D:\D-ART\Abstrakt_ART\CM\CM-1_(4^2-1)-2017-06-29-01\CM-1_(4^2-1)-2017-06-29-01-0001-01-01.jpg’ with mode ‘wb’.

Most probably the reason is that the output folder and file name is mutilated:
the folder that was generated with mkdir for the batch run is: D:\D-ART\Abstrakt_ART\CM\CM-1_(4$z^2-1)-2017-06-29-01
the derived file name is folder name with some indexes: CM-1_(4$z^2-1)-2017-06-29-01\CM-1_(4$z^2-1)-2017-06-29-01-0001-01-01.jpg

According to the error message the folder and file name was mutilated in the part that is coding the used complex function: 1_(4^2-1) instead 1_(4$z^2-1) (half-decent file system compatible coding for ‘1/(4*z^2-1)’).

What is going on here and how to fix it? Thanks!

(because it runs on Win I have not tested if and how backslashing the given quotes and parentheses in the -fx_conformal_maps substring is necessary)

The command works for me. I don’t have your input file, so I used another one. Output filename:


What I did was change 4$z^2-1 to 4{z}^^2-1.

  • z is a predefined variable. To evaluate it, use { }, but be careful where it is evaluated in the buffer and from which image it is evaluating, as it might vary. If your command is long, I suggest you assign the z value to another variable. For my input file, z=0.

  • ^ is a special character in cmd.exe, so you need to escape it with another ^.

1 Like

Thanks for answering. You have

  1. let the formula expression in -fx_conformal_maps unchanged: “1/(4*z^2-1)”
  2. and changed the coding of the formula in the folder and file name from 1_(4$z^2-1) to 1_(4{z}^^2-1).
    That generates no output error and a file name: CM-1_(40^2-1)-2017-06-29-01-0001-01-01.jpg

The obvious problem is that the resulting coding of the expression in the name “1_(40^2-1)” can not be remapped to the original expression “1/(4*z^2-1)”.

If the problem is only the “z” in the name coding then it can easily be solved by using an other variable name because this serves only to remember what formula was used. Can “Z” or “W” be used without be interfering to the predefined variables?

Some more strange behaviour:
I tried the name coding with: CM-1_(4$W^^2-1) and now GMIC tries two times to process the input image first using the coding CM-1_(4^^2-1) and secondly CM-1_(4^2-1) resulting both in error because such folders do not exist.

The real problem is the coding of the multiplication sign, the “$”. If I test a change to “X” I get no error and a folder name CM-1_(4Xz^2-1)-2017-06-29-01.

For the first time I see now a result image from GMIC command line and it is not what I expected!! I made an example and publish the results in flickr:
input image:
reference result from Gimp with same parameter:
result with command line:

It seems that the command line image is a small detail from the center of the Gimp result but both images were generated with the same parameter setting.

If you haven’t already, please take a look at the reference page here: It may help you address some of your questions.

Maybe I misunderstood your question, or am just plain tired. Are you concerned about the usage of -fx_conformal_maps, -output or something else?

Generally, it is not advisable for you to use reserved system characters to name your files since it can cause major problems or at least misunderstandings. My suggestion is that you redirect these commands to a separate file. (There are cool things you could do with that.) Read more about that here: Command Redirection, Pipes - Windows CMD -

If you don’t want to use z as

‘z’: current processed slice of the associated image, if any (0 otherwise).

but still want to use z, then you can still assign a value to it like this z=10 and call it using $z.

@ afre: Months ago I tried to get a strategy how to reversible map expressions to folder and file names ( but I got no feedback. The question are the operations (±/^) that occur in the formulas for conformal maps. I collected the signs that are not allowed and those that should not be used and I substitute “/” with “_” (allowed) and "" with “§” (no info that it should not be used) which works in the context of Matlab and the processing of conformal maps there. Now I tried to work with GMICs command line and Perl scripts that call GMIC (on Win) and I had to look in Pandoras UTF-8-box because § can not be used for file system names (substitution delivers ┬º) and I do not have the nerves to learn Win32::API::Files for this sideline. Using now “X” for “*” (like CM-1_(4Xz^2-1)-2017-06-29-01) in the GMIC context is an unpleasant inconsistency with all the hundreds of image populations I made with Matlab but I see no other way at the moment. I accept it for now because I do not know how far I come with GMIC considering the parameter inconsistency with my Flickr example.

What you are asking isn’t sensible: it is over-complicating matters. I guess people were polite enough to not answer rudely but not kind enough to give you proper advice. Hopefully we can do better here :slight_smile:. Like I said above, try redirecting the info to a separate file.

Say I have the following command:

gmic -sp tiger -fill 0.5*(i(x+1)-i(x-1)) -n 0,255 -o new_tiger.png

and I would like to keep a record of what I did. Instead of naming the output file


I could store this info in a separate file like so

gmic -sp tiger arg="0.5*(i(x+1)-i(x-1))" -fill $arg -n 0,255 -o new_{n}.png ^
-echo_stdout "\"{n}\" \"$arg\" new_\"{n}\".png" > gmic_args.txt

(Note: I split the command into two lines to make it readable here using ^ at the end of the first line.)

and repeat the command later by doing this

for /f "tokens=1-3" %i in (gmic_args.txt) do gmic -sp %i -fill %j -n 0,255 -o _%k

I added an underscore to the second file to demonstrate that new_tiger.png and _new_tiger.png are identical. This is only an example of what is possible. I am not a programmer, mathematician or have any background in the stuff that I just told you. I just spent some time tinkering and learning from others over the years. So, I am sure you can figure out the rest yourself. Hope this helps :slight_smile:.

@patdavid @paperdigits Maybe add some tags to this thread, as it is not just about G’MIC.

Sure - what tags would you think are most appropriate?

I’m not sure, but this seems to be more related to Windows command-line syntax (that’s also why I couldn’t help for this issue :p).

I added tags I thought were appropriate.

1 Like

I am not prepared to get into batch processing (bat/ps) so probably using the cmd.exe and/or Windows tag(s) would suffice. There are plenty of resources and communities that deal with that topic at length. Here, I am merely trying to give @gubach some ideas and encouragement.

You can use any characters in a filename allowed by the file system you’re using as long as you learn to escape them properly. To verify that you escaped them properly you can do something like echo yourfilename, for example
echo "D:\D-ART\Abstrakt_ART\CM\CM-1_(4$z^2-1)-2017-06-29-01\CM-1_(4$z^2-1)-2017-06-29-01-0001-01-01.jpg", and see what that produces.

Characters not allowed by a filesystem or OS can be substituted with lookalikes, e.g. substitute * with × (multiplication symbol U+00D7) and / with ∕ (division slash U+2215).

However the whole approach is bad. Since @gubach can script, the formulae could be stored more safely and reliably as metadata or in sidecar files.