0

Sorry for any errors, english is not my native language

I'm in need of a certain script to manipulate a bunch of images, to not bother people to death by asking "can someone do this for me?", i'm trying to learn how to write them myself.

I start by creating a script that will move images from one folder to another, from /Images/origin to /Images/destination, I need this to be a relative path since i need it to work anywhere as long as theres a origin and destination folder inside a Images folder.

Currently I have the next script (taken from what i could learn, copy and understand) but when saving an image it doesn't save where i expect it to go, actualy it does nothing.

(define (batch-move)  
   (let* (filelist (cadr (file-glob "/Image/origin/*.png" 1))))  
   (while (not (null? filelist)) 
      (let* ((filename (car filelist))  
      (image (car (gimp-file-load RUN-NONINTERACTIOVE filename filename)))  
      (draw (car (gimp-image-get-active-layer image)))  
      (gimp-file-save RUN-NONINTERACTIVE image draw filename/../destination filename)  
   (set! filelist (cdr filelist))
))))

The place where is the function(?) gimp-file-save, i've tried to put the path before, and in this example after, but it doesn't work.

This is assuming the filename is the complete path using /../ to go back a folder and /destination/ go to the next, same way as to navigate windows using relative path directories

I also understand that the gimp-image-get-active-layer is probably not necessary but this is for me to later add all the functions that i need.

And my question is why is it not working?, from what I gather the filename variable is the entire path, but if it isn't then what is is?

  • If you need to manipulate a bunch of images, GIMP is not the best choice. Better use some imaging library like PIL (for python) or others depending on you preferred programming language. Il will be faster. – Valentino Dec 23 '18 at 23:48
  • I'm trying GIMP because it already has the functions i need to implement, and already played around with the values that i find give the best result. In python, from what i can find, i would need to implement several functions to achive the same results, but yeah if i can't get this to work i'll try using python instead. – megacrazyman Dec 23 '18 at 23:55
  • Most of the trivial stuff (scale, crop, rotate, add annotations) are more easily handled with [ImageMagick](https://www.imagemagick.org/script/index.php) which is really designed to be used from the command line or in shell scripts. For a sample Gimp python script called from the command line, see [here](https://stackoverflow.com/questions/44430081/how-to-run-python-scripts-using-gimpfu-from-windows-command-line/44435560#44435560). – xenoid Dec 24 '18 at 10:03

0 Answers0