Question

I would like to convert a number of .XCF image to .PNG images within a PHP script. (Flattening layers, preserving transparency, and honouring the layer visibility setting).

It seems that you can call the GIMP in command line mode and use its script-fu language to do this. I have found various answers to similar problems, however there is so much going on in the solutions that I can figure out how to run them properly and adapt them to PHP.

Here's an example that I tried to use - its supposed to find all the .XCF files in a directory and convert them to PNGs.

        $execStg = ' "C:\Program Files\GIMP 2\bin\gimp-2.8.exe" -n -i -b - <<eof (let*="" (="" (file\'s="" (cadr="" (file-glob="" "*.xcf"="" 1)))="" (filename="" "")="" (image="" 0)="" (layer="" )="" (while="" (pair?="" file\'s)="" (set!="" image="" (car="" (gimp-file-load="" run-noninteractive="" file\'s))))="" layer="" (gimp-image-merge-visible-layers="" clip-to-image)))="" filename="" (string-append="" (substring="" 0="" (-="" (string-length="" file\'s))="" 4))="" ".png"))="" (gimp-file-save="" filename)="" (gimp-image-delete="" image)="" file\'s="" (cdr="" (gimp-quit="" eof<="" pre=""> ';
        exec($execStg, $results);

http://www.gimptalk.com/index.php?/topic/46715-batch-convert-xcf-to-png/page_p_354668#entry354668

I couldnt get this to work (I also tried running the command in a DOS box).

What I really want to do is adapt this script so I can specify a number of file names to be converted to pngs. Can anyone give me a hand adapting the above script (or provide something equivalent).

(I would prefer if the entire script is contained in my PHP file rather than having other bits in other places such as in GIMP's plug-in folder.)

Était-ce utile?

La solution

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top