It is currently Sat Jul 20, 2024 12:20 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: use specific gmic-plugin to batch image processing
PostPosted: Sat Jan 11, 2014 2:05 pm  (#1) 
Offline
GimpChat Member

Joined: Jan 11, 2014
Posts: 5
Hi people,
i'll try to restaurate a dv video.

1) Before with avconv tool i extract frame from video and saved it in png format
avconv -y -i "/sourcepath/nameovvideo.dv" -an -vcodec png "/destpath/pic%04d.png"


2) After i would try to use some plugin of g'mic for these png
#!/bin/bash
echo "Source folder of png: "
read sourcefolder
cd $sourcefolder
echo "Destination folder of png: "
read destfolder
mkdir $destfolder
   time for i in *.png
      do
      gmic $i -nameofplugin varofplugin -o $pathsource/$destfolder/$i
   done
exit 0

3) Last thing to do is making from png frames a video

avconv -i "/pathofpng/pic%04d.png" -vcodec huffyuv -pix_fmt rgb24 "/finalpath/output.avi"


Now my problem is i can't determine the name of plugin and the param i set...
I'll try with calling gimp into terminal, open a single frame, select gmic filter, set message (console), select the filter (like Repair->Pixel denoise), read what is on terminal (in this case [gmic_gimp]./apply/ -v -99 -iain_pixel_denoise_p 1,10,3,0,1), after i open new one, and try this, but doesn't work (only one work is -deinterlace 0,0 that is the same i read into terminal):
marco@android:~/Immagini/out11$ gmic pic0001.png -iain_pixel_denoise_p 1,10,3,0,1 -o elab/pic0001.png
[gmic]-0./ Start G'MIC parser.
[gmic]-0./ Input file 'pic0001.png' at position [0] (1 image 720x576x1x3).
[gmic]-1./ Input file '-iain_pixel_denoise_p' at position [1]
[gmic]-1./ *** Error in ./ *** Unknown command or filename '-iain_pixel_denoise_p'.
[gmic]-1./ Abort G'MIC instance.

[gmic] *** Error in ./ *** Unknown command or filename '-iain_pixel_denoise_p'.


PS: I have also installed BIMP, but seems not like g'mic and works only for plugin of gimp...
Thanks!


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: use specific gmic-plugin to batch image processing
PostPosted: Sat Jan 11, 2014 3:49 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
The 'Iain's denoise filters' are not a part of the 'gmic' binary by default, but only a part of the GIMP plug-in, since the code of these functions are defined in external filter sources.
Nothing we cant solve however :)

Solution : Get the 'updateXXXX.gmic' file from the Sourceforge server (where XXXX is replaced by your G'MIC version number, e.g. 1582 for the latest), the Iain's denoise filters are

1. To display the version number : 'gmic -version'.
2. Get then the update data file : http://gmic.sourceforge.net/update1582.gmic
3. Add it just after the gmic invokation, then your command should be recognized :

$ gmic update1582.gmic pic0001.png -iain_pixel_denoise_p 1,10,3,0,1 -o elab/pic0001.png

That's it. It should solve your problem.


Top
 Post subject: Re: use specific gmic-plugin to batch image processing
PostPosted: Sat Jan 11, 2014 9:02 pm  (#3) 
Offline
GimpChat Member

Joined: Feb 13, 2013
Posts: 86
moroboshi_84 wrote:
-iain_pixel_denoise_p 1,10,3,0,1


I should point out that while 10 iterations will give you a strong effect, there will be very little difference between that and 4-5 iterations, but it will take much longer.


Top
 Post subject: Re: use specific gmic-plugin to batch image processing
PostPosted: Tue Jan 14, 2014 11:10 am  (#4) 
Offline
GimpChat Member

Joined: Jan 11, 2014
Posts: 5
Thanks guys...
I'll try to rewrite mine script and now working...
#!/bin/bash
#Costanti -> upper
#Variabili locali -> prima lettera upper
#File -> lettere under

clear

#Imposto la costante YES
YES="y"
NO="n"
ZERO="0"

#Imposto l'user agent
UA="Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0"

#Imposto il tipo di file
TYPE="*.png"

#Imposto cartella di default
DEFAULT=$HOME/Immagini

#Imposto la cartella locale per bgmic
BGMIC=$HOME/.bgmic
echo "BGMIC : " $BGMIC

#Controllo l'esistenza della cartella locale di bgmic
if [ ! -d $BGMIC ]; then
   mkdir $BGMIC
fi

#mi sposto sulla cartella locale di bmic
cd $BGMIC

#Controllo la versione di gmic e scarico il file per usare i filtri è del tipo
#SORRYBUTCANTPASTELINK/update1582.gmic
gmic -version &> version
Gmicversion=`echo | grep -r 'Version' version | cut -d',' -f1`
Gmicversion=`echo $Gmicversion  | cut -d' ' -f2 | tr -d '.'`
echo "Version: " $Gmicversion
Filegmic=update$Gmicversion.gmic

#controllo se esiste il file per usare i plugin gmic
if [ ! -f $Filegmic ]; then
   echo "Non esiste " $Filegmic " lo scarico"
   wget -U "$UA" "SORRYBUTCANTPASTELINK$Filegmic" -O $Filegmic
fi

#determino la path di elaborazione default o last
if [ ! -f lastsource ]; then
   echo "Non esiste lastsource mi sposto sulla cartella Immagini"
   Lastsource=$DEFAULT
else
   Lastsource=`cat lastsource`
fi

if [ -d $Lastsource ]; then
   echo "Lastsource: " $Lastsource
else
   echo "Il file lastsource è vuoto, imposto al valore di default cartella Immagini"
   Lastsource=$DEFAULT
fi

#Chiedo cartella delle immagini da elaborare
echo "Cartella con le immagini da elaborare: (default : " $Lastsource")"
read Sourcefolder

if [ -z "$Sourcefolder" ]; then
   echo "Valore di default"
   Sourcefolder=$Lastsource
fi

find $Sourcefolder/$TYPE -type f -printf "%p$IFS"|sort > listfilesource

#ripeto la domanda finchè non mi darà una cartella con file da elaborare
while [ ! -s listfilesource ]
   do
      echo "Cartella con le immagini da elaborare: "
      read Sourcefolder
      find $Sourcefolder/$TYPE -type f -printf "%p$IFS"|sort > listfilesource
done

#salvo la cartella per prossime elaborazioni
echo $Sourcefolder > lastsource

#determino la path degli elaborati default o last
Defaultdest=$Sourcefolder/elab
if [ ! -f lastdest ]; then
   echo "Non esiste mi sposto sulla cartella Immagini/elab"
   Lastdest=$Defaultdest
else
   Lastdest=`cat lastdest`
fi

if [ -d $Lastdest ]; then
   echo "Lastdest: " $Lastdest
else
   echo "Il file lastdest è vuoto, imposto al valore di default cartella Immagini/elab"
   Lastdest=$Defaultdest
fi

#chiedo la cartella dove salvare le immagini elaborate
echo "Dove vuoi salvare le immagini elaborate: (default : " $Lastdest ")"
read Destfolder

if [ -z "$Destfolder" ]; then
   echo "Valore di default"
   Destfolder=$Lastdest
fi

#controllo l'esistenza della cartella di destinazione
if [ ! -d $Destfolder ]; then
   echo "Non esiste la cartella"
   mkdir $Destfolder   
fi

#salvo la cartella per prossime elaborazioni
find $Destfolder/$TYPE -type f -printf "%p$IFS"|sort > listfiledest
echo $Destfolder > lastdest

#chiedo se vuole editare il file dei filtri
echo "Vuoi editare il file dei filtri: (default : y)"
read -s -n 1 Edit

if [ "$Edit" == "$NO" ]; then
   echo "vale o N o n"
else
   echo "lo faccio valere y"
   Edit=$YES
fi

if [ ! -f filter ]; then
   echo "Non esiste il file"
   Edit=$YES   
fi

if [ "$Edit" == "$YES" ]; then
   vi filter   
fi

#determino quanti file ci sono nelle due cartelle
wc -l listfilesource &> totalsource
wc -l listfiledest &> totaldest

Totaldest=`cat totaldest`
Totaldest=`echo $Totaldest | cut -d' ' -f1 | cut -d'=' -f2`
TOTALDEST=$Totaldest

Totalsource=`cat totalsource`
Totalsource=`echo $Totalsource | cut -d' ' -f1 | cut -d'=' -f2`
Totalelab=$[Totalsource-Totaldest]
Currentelab="0"

#determino la lunghezza delle path
Lsourcefolder=${#Sourcefolder}+1
Ldestfolder=${#Destfolder}+1

#valorizzo i due array con i file contenuti nelle due cartelle
Listfilesource=`cat listfilesource`
Listfiledest=`cat listfiledest`

#Carico il file dei filtri
Filter=`cat filter`

elaborazione() {
               clear
               echo "Nome file in elaborazione: " $i
               Totaldest=$[Totaldest+1]
               Currentelab=$[Currentelab+1]
               echo $Totaldest"/"$Totalsource
               echo $Currentelab"/"$Totalelab
               gmic $Filegmic $i $Filter -o $Destfolder/$Filenamesource
               echo "$Destfolder/$Filenamesource" >> listfiledest
}

time for i in $Listfilesource
   do
      Filenamesource=${i:$Lsourcefolder}
      if [ ! -f $Destfolder/$Filenamesource ]; then
         elaborazione
      fi
   done
exit 0


But if i want to pipe a gimp built-in plugin how i do that?
I know i had to do somethings like this:
gimp -i -b '(nameofplugin "sourcefile" eventual parm)' -b '(gimp-quit 0)'


Top
 Post subject: Re: use specific gmic-plugin to batch image processing
PostPosted: Tue Jan 14, 2014 12:35 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Look at the example file 'gmic_in_script.scm', where the G'MIC plug-in is invoked from a script. It should work the same as in your command line call :

https://sourceforge.net/p/gmic/source/c ... script.scm


Top
 Post subject: Re: use specific gmic-plugin to batch image processing
PostPosted: Wed Jan 15, 2014 8:48 am  (#6) 
Offline
GimpChat Member

Joined: Jan 11, 2014
Posts: 5
Ronounours wrote:
Look at the example file 'gmic_in_script.scm', where the G'MIC plug-in is invoked from a script. It should work the same as in your command line call :

ICANTPASTEOURLINK

Hi Ronounours...
so i have to write this scm and put it into /home/user/.gimp-2.8/scripts;
changing the permission to the file
chmod 777 $HOME/.gimp-2.8/scripts/gmic_in_script.scm

after doing a call in this way:
gimp -i -b '("/home/marco/.gimp-2.8/scripts/gmic_in_script.scm" "/home/marco/Immagini/Nuovo/pic0001.png" "/home/marco/.bgmic/update1582.gmic -deinterlace 0,0 -iain_pixel_denoise_p 1,10,0,0,1 -o /home/marco/Immagini/Nuovo/0001.png")' -b '(gimp-quit 0)'

but obtain only an error:
batch command experienced an execution error:
Error: ( : 1) illegal function


Top
 Post subject: Re: use specific gmic-plugin to batch image processing
PostPosted: Wed Jan 15, 2014 10:27 am  (#7) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
moroboshi_84 you have misunderstood two things.

The example script David pointed you to, uses G'MIC in a very specific way, and is not a general purpose way of feeding in your G'MIC commands. It has also been written to operate on images that are already open in an interactive instance of GIMP - so it's not suitable to to be used from the command line in it's current form.

Secondly you have misunderstood how to call plug-ins from the command line.
The first parameter in the -b section is the plug-in name NOT the file path to the plug-in.

Kevin


Top
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Problem with David's Batch Processor plugin

22

No new posts ofnut colormap-to-layer plugin + BATCH

0

No new posts Help finding GMIC plugin

3

No new posts Cant load GMIC plugin in gimp

2

No new posts Attachment(s) How to get the Display from a new image created with Gmic ?

5



* Login  



Powered by phpBB3 © phpBB Group