The script I wrote (see below) would work on one of two layers that made up image (3600x2400 pixels). The two layers are interlaced, so one layer would have 7 or 8 pixels of transparency, then 7 or 8 pixels of colour, and visa versa. The script is supposed to find these vertical lines of colour information, and flip each individual one vertically.
And it works, so that's not the issue. However, while the image size in gimp is measured in a couple of 10's of MB's, the undo file for the script ends up in excess of 8 GB, meaning it'll get through the available RAM halfway the process and use virtual memory afterwards. I get the feeling I'm using the template for a new script wrong or am unaware of a particular function requiring the storage. Perhaps I'm being stupid in some other way. Would anyone know what I'm doing wrong?
(define (script-fu-lentflip img drawable)
(gimp-image-undo-group-start img)
(gimp-context-push)
(let* ((x 0))
(while (< x 3599)
(if (= (vector-ref(cadr(gimp-drawable-get-pixel drawable x 0)) 3) 255)
(begin
(if (= (vector-ref(cadr(gimp-drawable-get-pixel drawable (+ x 8) 0)) 3) 255)
(begin
(gimp-rect-select img x 0 8 2400 2 0 0)
(gimp-item-transform-flip-simple drawable 0 1 0)
(set! x (+ 9 x))
)
(begin
(gimp-rect-select img x 0 7 2400 2 0 0)
(gimp-item-transform-flip-simple drawable 0 1 0)
(set! x (+ 8 x))
)
)
)
)
(set! x (+ x 1))
)
)
(gimp-context-pop)
(gimp-image-undo-group-end img)
(gimp-displays-flush)
)