title: Why are these scripted gimp image modifications not being persisted?
body: <p>This is my first foray into <code>gimp</code> scripting, and I seem to be having some basic misunderstanding. I've written the following code which is intended to convert white into transparency in the specified file, and to export the result as a <code>png</code> file:</p>
  
  <pre><code>(define (edit-name original-name)
    (let* ((pos (- (string-length original-name) 4))
      (suffix (substring original-name pos))
      (prefix (substring original-name 0 pos))
      (new-name (string-append prefix ".png")))
      new-name))
  
  (define (my-process filename)
      (let* ((color '(0 0 0))
             (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
             (drawable (car (gimp-image-get-active-layer image)))
             (filename-modified (edit-name filename)))
          (if (not (gimp-drawable-is-rgb drawable))
              (gimp-image-convert-rgb image))
          (plug-in-colortoalpha RUN-NONINTERACTIVE image drawable color)
          (file-png-save2 RUN-NONINTERACTIVE image drawable filename-modified filename-modified 0 9 1 1 1 1 1 0 1)))
  </code></pre>
  
  <p>This script is saved in the file <code>~/.gimp-2.8/scripts/my-process.scm</code> and is invoked with:</p>
  
  <p><code>gimp -i -b '(my-process "somefile.xcf")' -b '(gimp-quit 0)'</code></p>
  
  <p>The script appears to run and I get output on the console saying <code>batch command executed successfully</code>. Furthermore, if I put an obvious syntax or parameter error into the script then I get an error. I've also tried re-getting the drawable after the rgb conversion, in case the conversion results in a different object. I've also tried using <code>file-png-save-defaults</code> instead of <code>file-png-save2</code>, to no avail.</p>
  
  <p>However, the output I get is a simple png export in indexed color mode (the original mode of the source image), which does not contain the alpha channel.</p>
  
  <p>I've looked at the documentation for the conversion steps I'm using and cannot figure out what's going on; help would be much appreciated.</p>