GIMP Chat
http://gimpchat.com/

Newbie alert: loading numbered files for G'MIC transformation
http://gimpchat.com/viewtopic.php?f=28&t=19216
Page 1 of 1

Author:  ObiWanCeleri [ Sun Mar 07, 2021 2:17 pm ]
Post subject:  Newbie alert: loading numbered files for G'MIC transformation

Hello!

I recently tried my camera on a night shot (in the middle of a snow storm) and ... let's just say the footage was atrocious. I got the green pixel servings of death LOL
To salvage the result I extracted all the images as individual .PNG files (with the VLC player) and decided to go the G'MIC command line way with the following batchfile :
Note: There's 240 pictures in all
@Echo off
FOR /f "tokens=*" %%G IN ('dir IN\*.png /b') DO (call :subroutine "%%G")
Pause
GOTO :eof

:subroutine
gmic -input IN/%1 fx_dreamsmooth 3,0,1,0.8,0,0.8,4,24,0 jl_colorgrading 0.127,-3,1,1,-10,-15,50,10,0,0,1,0.442,0,0,70,0,0,0,0,0,70,180,0,1.092,0,10,0 -output OUT/%1

GOTO :eof

This code passes every file from the IN\ folder, does a few G'MIC operations and then saves the result (with the same name) into the OUT\ folder

This works great ... until you have 5-6 operations and then the command line is too big to be processed.
I think I've read the whole damn manual and I'm only finding partial answers and no solutions. :gaah

I'm trying to find :
- A way to bypass the command line length limitation?
And/ or
- A way to import a script file into G'MIC --> gmic @scriptfile.txt
And / or
- A way to create a G'MIC script that will load all the pictures in sequence and do all the operations I require

I don't really want to create a custom filter unless I don't have a choice (it's not meant to be part of a GUI or whatnot).
I'd rather do all the processing in one shot instead of calling G'MIC multiple times (I "preview" the operations in GIMP so they can be processed linearly using only G'MIC)
Each filename is padded with zeros so that's to be considered if we ask G'MIC to load files sequentially (scene00001.png, scene00002.png, scene00003.png, etc).

Any help will be really appreciated!
I might also post a link to the final video if I can get this to work ;)

I'm using G'MIC CLI 2.9.6

Author:  Tas_mania [ Sun Mar 07, 2021 4:28 pm ]
Post subject:  Re: Newbie alert: loading numbered files for G'MIC transformation

Welcome to Gimp Chat ObiWanCeleri. Possibly this tutorial could help.
How To Run A GMIC Filter On Hundreds Or Thousands Of Layers

With this method you can run the G'MIC commands after each other so your computer never chokes on too much data.

Author:  ObiWanCeleri [ Sun Mar 07, 2021 10:13 pm ]
Post subject:  Re: Newbie alert: loading numbered files for G'MIC transformation

Interesting! Thanks!
I've also found out you could get a huge helpfile by doing the following command line:
gmic -help > help.txt


Another thing I will investigate is if I can use a video file as an input file and output individual .PNG files.

I'm going to do some more reading me thinks :)

Author:  Tas_mania [ Sun Mar 07, 2021 10:48 pm ]
Post subject:  Re: Newbie alert: loading numbered files for G'MIC transformation

video to frames or PNG's is easy with ffmpeg.
ffmpeg -i input.mp4 -vf fps=24 file%d.png

Author:  ObiWanCeleri [ Mon Mar 08, 2021 2:58 am ]
Post subject:  Re: Newbie alert: loading numbered files for G'MIC transformation

Thanks for your help Tas_mania; I've found my culprit (should have read the error messages LOL)
So cut and pasting from the G'MIC plugin in Gimp gave me the following command:
fx_morphological 1,2,5,"1,0,1; 0,1,0; 1,0,1",0,0,34,0,0,50,50


Feeding that into GMIC (on a Windows command line) spits our error $4. I had a hunch the GMIC interpreter didn't like quotation marks (...)
So you need to escape them (with a backslash) for the script to work:
fx_morphological 1,2,5,\"1,0,1; 0,1,0; 1,0,1\",0,0,34,0,0,50,50


I also was wrong about the limit for a line in Window's command prompt. It's 8191 characters.
So I have lots of space to make complex commands, so long as you don't expect to see a nice layed out batch file.

Will upload the original and final result tomorrow to give you guys an idea of the results.

Author:  Tas_mania [ Mon Mar 08, 2021 3:02 am ]
Post subject:  Re: Newbie alert: loading numbered files for G'MIC transformation

Good on you ObiWanCeleri. I'm sure some Windows G'MIC users will use that escape sequence. :bigthup

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/