GIMP Script-fu

Check-in [43ae3729f9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Script per liquidape (IRC request)
Timelines: family | ancestors | descendants | both | sg-layer-bake
Files: files | file ages | folders
SHA1:43ae3729f9f8e919f07c8e49acb2004655cc4119
User & Date: saul 2015-05-22 21:36:50
Context
2015-05-22
22:58
Fixed handling of layer groups. Leaf check-in: 9d264df06f user: saul tags: sg-layer-bake
21:36
Script per liquidape (IRC request) check-in: 43ae3729f9 user: saul tags: sg-layer-bake
21:34
Create new branch named "sg-layer-bake" check-in: c4e75ba86e user: saul tags: sg-layer-bake
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added sg-layer-bake.scm.























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.

(define (script-fu-sg-layer-bake image)
  (gimp-image-undo-group-start image)
  (let ((composite-layer (car (gimp-layer-new-from-visible image image "composite")))
        (orig-sel (car (gimp-selection-save image))))
    (let loop ((layers (vector->list (cadr (gimp-image-get-layers image)))))
      (unless (null? layers)
        (unless (zero? (car (gimp-drawable-has-alpha (car layers))))
          (gimp-image-set-active-layer image (car layers))
          (let ((layer (car (gimp-layer-copy composite-layer TRUE)))
                (name (car (gimp-item-get-name (car layers)))))
            (gimp-image-insert-layer image layer 0 -1)
            (gimp-image-select-item image CHANNEL-OP-REPLACE (car layers))
            (gimp-selection-invert image)
            (gimp-edit-clear layer)
            (gimp-image-remove-layer image (car layers))
            (gimp-item-set-name layer name)))
        (loop (cdr layers))))
    (gimp-image-select-item image CHANNEL-OP-REPLACE orig-sel)
    (gimp-image-remove-channel image orig-sel))
  (gimp-image-undo-group-end image))
  
(script-fu-register "script-fu-sg-layer-bake"
  "Layer Bake"
  "Bake all layers per liquidape"
  "Saul Goode"
  "saulgoode"
  "May 2015"
  "*"
  SF-IMAGE    "Image"    0
  )
(script-fu-menu-register "script-fu-sg-layer-bake"
  "<Image>/Filters/Misc"
  )