Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Resize all layers in script-fu
#1
Hi all! I've got a bit of a question about scripting. I'm trying to get a script to resize two both layers of an image instead of just the active one, but I'm not entirely sure how to go about doing that. First, I set up the image with this script:
Code:
(define (script-fu-mua-xml2-single-preview)
    (let*
        (
            (theImageWidth  543)
            (theImageHeight 1080)
            (theImage
                (car
                    (gimp-image-new
                       theImageWidth
                       theImageHeight
                       RGB
                    )
                )
            )
            (backgroundLayer
                (car
                    (gimp-layer-new
                        theImage
                        theImageWidth
                       theImageHeight
                       RGBA-IMAGE
                       "Background"
                       100
                       LAYER-MODE-NORMAL
                    )
                )
            )
            (portraitLayer
                (car
                    (gimp-layer-new
                        theImage
                       theImageWidth
                       theImageHeight
                       RGBA-IMAGE
                       "Portraits"
                       100
                       LAYER-MODE-NORMAL
                    )
                )
            )
        )
        (gimp-image-add-layer theImage backgroundLayer 0)
        (gimp-image-add-layer theImage portraitLayer 0)
        (gimp-image-set-active-layer theImage backgroundLayer)
        (gimp-display-new theImage)
    )
)

I then do some work with that image and export it. After that, I want to double the width of the image by resizing the canvas. In doing so, I want all the layers to resize as well. Here's what I have so far:
Code:
(define (script-fu-mua-xml2-double-preview image layer)
    (gimp-image-undo-group-start image)
    (gimp-selection-none image)
    (gimp-image-resize image 1086 1080 0 0)
    (gimp-layer-resize-to-image-size layer)
    (gimp-displays-flush)
    (gimp-image-undo-group-end image)
)

I cut out some extra stuff from both scripts like some codes to add vertical/horizontal guides in various places which all works the way I want it to. Generally, I have the top layer selected when I execute the second script, so the top layer is resized, but the bottom one isn't. I want it to be able to resize both layers to the image size, though, regardless of which one I have actively selected (if it's possible to do so). How do I go about doing that?
Modder/Skinner at MarvelMods.com using GIMP to create, edit, and export textures and previews more efficiently.

My GIMP scripts hosted on GitHub
Reply


Messages In This Thread
Resize all layers in script-fu - by BaconWizard17 - 10-23-2022, 04:08 PM
RE: Resize all layers in script-fu - by Ofnuts - 10-23-2022, 07:17 PM
RE: Resize all layers in script-fu - by teapot - 10-26-2022, 11:00 PM
RE: Resize all layers in script-fu - by teapot - 10-26-2022, 11:46 PM

Forum Jump: