Question from a programming green
How to Install (CLI) gmic in Windows 11?
and how to apply correctly ?
It couldnât be simpler.
To âinstallâ:
- Download the .zip archive here: https://gmic.eu/get_file.php?file=prerelease/gmic_cli_win64.zip
- Unzip it somewhere, it will create a folder like
gmic-3.5.3-cli-win64/
. - Inside this folder, there is the executable
gmic.exe
To use:
- Open your favorite terminal (
cmd.exe
maybe), then go to the folder containinggmic.exe
. - You can now execute
gmic.exe
, e.g.gmic.exe sample david
You could add it into path, so you can use it everywhere. My CLI path starts on system32, so I donât mess with my gmic-community work.
Then Start Here.
hank you sincerely for your advice - I am starting the experience.
I have a folder and in it are several photos.
In this folder, I placed the gmic folder (renamed from pbranego gmic_3.5.0_cli_win64)
Iter now I would like to learn how to use the G`MIC command from the clipboard, for batch editing.
Something is trying and going wrong.
By the way, at my 91 years, Iâm taking care not to get rusty -
Guess: What is âgoing wrongâ is that Windows 11 cannot find the gmic.exe
executable.
Going on that guess, what @David_Tschumperle suggests and what you have done are not quite the same steps. @David_Tschumperle suggestion leads to gmic.exe
being in the same folder as the images to be worked on. What you have done is placed the folder containing gmic.exe
with the images to be worked on. So the gmic
executable, in fact, is in a subfolder with respect to those images. When Windows tries to find commands, it first looks in the current directory. It wonât find gmic.exe
because it is in a sub-folder. Nor will Windows look in any other folder save those which have been added to the PATH
environmental variable.
Long term, what @Reptorian suggests is best. Put gmic.exe
in any folder you choose, named any way you care to, though I would suggest âLocal_Executablesâ or some such. Then, open âEnvironment Variablesâ from System Properties, locate the âPathâ variable under âSystem Variablesâ, edit it, and add the path to âLocal_Executablesâ, separating it from the other paths with a semicolon. With success, Windows will follow your amended path and find gmic.exe
wherever you may be in your file system.
I am not a regular Windows 11 user. Appreciate it if anyone smarter about Windows could sane-wash my answer.
If I understood correctly, follow the advice with attachments given by afre w:
I thought there was a method more accessible to ordinary bread eaters
That was me replying to a specific command line question, in a bit more advanced context. If you have a one-off need, it should be fairly straightforward to do it in the Windows CMD (or even PowerShell) terminal window. Since you want to do multiple images, youâll need a loop, and Iâm not versed enough in the Windows tools to know that recipe off the top of my head.
Edit path gmic under user variables. - Yes
I copy the GMIC command to the clipboard and type it into cmd
I open the folder where I have the sample files and the cmd file.
I click cmd and for a blink the PowerShell window opens you can see the records and then nothing happens.
I have a question again what am I doing incorrectly, how should I do it ?
Hi,
the problem here lies with your use of the apply_files
command.
apply_files:
"filename_pattern",_"command",_first_frame>=0,
_last_frame={ >=0 | -1:Last },_frame_step>=1,
_output_filename
Your -fx_color_presets
command should be the 2nd argument of the apply_files command. But something tells me that it is not intended to be used in your case, but more with image sequences from a video. Iâve never used this command myself so i donât really know how it works.
If you donât have too many images or you do have a lot of RAM you can try :
gmic *.png foreach -fx_color_presets [params...] -o {b}.jpg rm done
gmic input_glob "*.png" foreach -fx_color_presets [params...] -o {b}.jpg rm done
But again, iâve never used Gâmic for batch processing so there is surely a better way.
This will load all images into RAM at the beginning and then process each one individually (foreach), output it as original_name.jpg (-o {b}.jpg) and remove it from memory (rm) (so you gradually recover your ram).
gmic run '-input_glob '*.png' foreach { -echo {n} }'
could float your boat. Prints out the name of every PNG in the current directory. The space following the opening outer {
and preceding the outer closing }
has parsing significance and should be retained. -echo {n}
is for demonstration purposes; replace it with something interesting. For me âSomething interestingâ is a custom command that Iâve written that does whatever needs to be done to each PNG in the current directory.
GâMIC works best interactively in command shells. Suggest avoiding the MSDos batch file approach; GâMIC has loads of native iterative constructs; foreach
is just one of them. Revisit Start Here, especially the first bit
, which examines the anatomy of command lines.
Gotta tip. New York City calls.
Mostly decent approach. Just this: -input doesnât do file globbing. Consider -input_glob. See my other reply.
$ gmic run '*.jpg foreach { -echo {n} }'
[gmic]./ Start G'MIC interpreter (v.3.5.3).
[gmic]./run/__run/ Input file '*.jpg' at position 0
[gmic]./run/__run/ *** Error *** Command 'input': Unknown filename '*.jpg'.
I see. Didnât know this input_glob
command.
i usually use run
too on Linux, but not this time. And *.jpg
works just fine without run
. Anyway, iâll just edit my answer, thanks!
EDIT: BTW, is there a way not to load all the images at the start? Iâve seen the files
command which lists the filenames and/or folders from a directory and outputs it in status ${}
, delimited by commas, but i donât know what to do next.
Didnât find the correct syntax to replace commas with spaces using strreplace
either.
@Zbyma72age Try this, using cmd.exe
:
- First, add
gmic
in yourPATH
:
> setx PATH "%PATH%;C:\path_to_your_gmic_folder\gmic-3.5.3-cli-win64
Then, close and restart cmd.exe
.
Then go to your folder with all your pictures, and try this:
First create a subfolder name processed
:
> mkdir processed
Then run gmic.exe
to process your images:
> gmic.exe v - files *.jpg files=${} repeat narg($files) { arg0 "$>,$files" file=${} v + e $file v - l[] { $file name={b} blur 10 o processed/$name.jpg,85 rm } }
where you can replace the blur 10
by any GâMIC pipeline you want (that takes one image as input, and output a single image).
Thank you very much.
The result was immediate, except that I had already set the path to gmic according to the recommendation given in:
Why I was so persistent with this idea.
Since I already wrote a tutorial => Batch editing in gimp_gmic_qt
and I found that it was too long and complicated a process, while there is simplicity and speed in this method.
I emphasize that I am not a programmer, but an amateur with 20 years of experience in G`MIC.
I have already written several guides in this regard.
Further it is my hobby to do something for others and not get rusty (I am 91 years old).
Thank you again
I have one more question;
If there are files with extension jpeg and jpg in the same folder then I have to use two scripts, or is there another method?
Or is there a method for all types of extensions in a folder ?
This should work:
Replace files *.jpg files=${}
by
files *.jpg files=${} files *.jpeg if narg($files)&&narg(${}) files.=,${} else files=${} fi
Again, thank you very much
But I have another inquiry:
How to integrate more complex processing, more commands from the clipboard?
Not sure what you mean by this. You may want to read the tutorials from @grosgood , it will teach you how GâMIC works in depth, and allow you to do almost everything you want with your images.
For example, can you paste in the same cmd, for example. two more commands from the clipboard