GIMP Chat
http://gimpchat.com/

Running gimp script on file from win command line doesn't work
http://gimpchat.com/viewtopic.php?f=9&t=15529
Page 1 of 1

Author:  ango [ Fri Apr 28, 2017 8:53 am ]
Post subject:  Running gimp script on file from win command line doesn't work

Hello,
i need this batch script to pass a jpeg to gimp console and run my script "CleanUpScan" on it.
The script also attempts to read the file and save it as .png.

The batch:
cd %~dp0
data\GIMPPortable\App\gimp\bin\gimp-2.8.exe -i -v -b '(CleanUpScan "C:\Users\C7X43T\Desktop\pngmin\CCI27042017.jpg")' -b '(gimp-quit 0)'
pause


CleanUpScan.scm as attachment.

Important snippets from the script:
Function header and variable declaration:
(define (CleanUpScan filename)
  (let* (   
         (img (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
            (nroflayers 0)
            (layers '())
            (height (car (gimp-image-height img)))
         (width (car (gimp-image-width img)))
            (index1 0)
         (y 0)
            (isCurrentLayerVisible #f)

        )

Saving the image as png:
;save image -> export as png
      ;get layer names (in an array)
       (set! layers (cadr (gimp-image-get-layers img)))
     (file-png-save2 0 img (aref layers 0) filename filename 0 9 1 0 0 1 0 0 1)

Problem: I suppose there is an issue with reading the file since the gimp process starts up and immediately shuts down.
Output on console:
(gimp-2.8.exe:8372): LibGimpBase-WARNING **: gimp-2.8.exe: gimp_wire_read(): error
batch command executed successfully



Attachment:
CleanUpScan.scm [6.5 KiB]
Downloaded 152 times

Author:  paynekj [ Fri Apr 28, 2017 11:29 am ]
Post subject:  Re: Running gimp script on file from win command line doesn't work

You can't use single-quotes on Windows command lines. Try this instead:

gimp-2.8.exe -i -v -b "(CleanUpScan \"C:\\Users\\C7X43T\\Desktop\\pngmin\\CCI27042017.jpg\")" -b "(gimp-quit 0)"

Author:  ango [ Sun Apr 30, 2017 10:07 am ]
Post subject:  Re: Running gimp script on file from win command line doesn't work

Thanks for your help,
this is how i got it to work:
cd %~dp0
"gimp-console-2.8" -b "(testloadsave \"C:\\Users\\C7X43T\\Desktop\\pngmin\\a.jpg\")" -b '(gimp-quit 0)'
pause
exit

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