You are here

Need a kick for unfold.scm to work

I am a rookie in scripting-fu , I am sure that I am missing a very basic thing.

I have written a very simple script (unfold.scm) sometime ago, which was working in previous versions of Gimp. But i could not manage it to work as expected in 2.8.

The script is supposed to unfold (copy + flip) 4 times an image to create tileable textures.

input image:

Output image:
/ \
\ /

However, output becomes as: /

The script is attached.

I appreciate any help.

unfold.scm2.73 KB
Original image612 bytes
Expected image760 bytes
But got this707 bytes

What happens in 2.8?

Please see the 3 images added.



  • Put these lines in comment to understand the problem.

;; (gimp-image-undo-group-start theImage)

;; (gimp-image-undo-group-end theImage)

  • Saves the file with the changes
  • Filters>Script-Fu>Refresh scripts
  • run your script
  • use "ctrl + z" to return to the first step
  • then "ctrl + y" to follow the different steps of the script
  • You will see that there is a problem during the "gimp-flip"
    The pasted layer is beyond the scope of the image.
  • You should rework your script as a whole because there are some deprecated procedures.

example: gimp-flip => "Deprecated: Use 'gimp-item-transform-flip-simple' instead."


  • There is no need for that line during the copy

(set! floating-sel (car (gimp-image-get-active-layer theImage)))

  • For the "undo", il 's "inImage"
  • For the "(set! theLayer....", it's "theImage"


(define (script-fu-unfold inImage inLayer)
(theHeight (* (car (gimp-image-height inImage)) 2))
(theWidth (* (car (gimp-image-width inImage)) 2))
(theImage inImage)
(theLayer 0)

(gimp-image-undo-group-start inImage)

(gimp-image-resize theImage theWidth theHeight 0 0)
(set! theLayer (car (gimp-image-get-active-layer theImage)))
(gimp-layer-add-alpha theLayer)
(gimp-layer-resize-to-image-size theLayer)

(gimp-context-set-transform-resize TRANSFORM-RESIZE-ADJUST)

(gimp-selection-all theImage)
(gimp-edit-copy theLayer)
(let ((floating-sel (car (gimp-edit-paste theLayer FALSE))))
(gimp-item-transform-flip-simple floating-sel ORIENTATION-VERTICAL TRUE 0)
(gimp-floating-sel-anchor floating-sel)

(gimp-selection-all theImage)
(gimp-edit-copy theLayer)
(let ((floating-sel (car (gimp-edit-paste theLayer FALSE))))
(gimp-item-transform-flip-simple floating-sel ORIENTATION-HORIZONTAL TRUE 0)
(gimp-floating-sel-anchor floating-sel)

(gimp-image-undo-group-end inImage)

Thank you very much both for the tips and the re-written code.

You saved my days froGgy factory.

Subscribe to Comments for "Need a kick for unfold.scm to work"