GIMP Script-fu

Hex Artifact Content
Login

Artifact acf1d96fec6ca700ad71d44bab40a97a3fba231f:


0000: 3b 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69  ; This program i
0010: 73 20 66 72 65 65 20 73 6f 66 74 77 61 72 65 3b  s free software;
0020: 20 79 6f 75 20 63 61 6e 20 72 65 64 69 73 74 72   you can redistr
0030: 69 62 75 74 65 20 69 74 20 61 6e 64 2f 6f 72 20  ibute it and/or 
0040: 6d 6f 64 69 66 79 0a 3b 20 69 74 20 75 6e 64 65  modify.; it unde
0050: 72 20 74 68 65 20 74 65 72 6d 73 20 6f 66 20 74  r the terms of t
0060: 68 65 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50  he GNU General P
0070: 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 61 73  ublic License as
0080: 20 70 75 62 6c 69 73 68 65 64 20 62 79 0a 3b 20   published by.; 
0090: 74 68 65 20 46 72 65 65 20 53 6f 66 74 77 61 72  the Free Softwar
00a0: 65 20 46 6f 75 6e 64 61 74 69 6f 6e 3b 20 65 69  e Foundation; ei
00b0: 74 68 65 72 20 76 65 72 73 69 6f 6e 20 32 20 6f  ther version 2 o
00c0: 66 20 74 68 65 20 4c 69 63 65 6e 73 65 2c 20 6f  f the License, o
00d0: 72 0a 3b 20 28 61 74 20 79 6f 75 72 20 6f 70 74  r.; (at your opt
00e0: 69 6f 6e 29 20 61 6e 79 20 6c 61 74 65 72 20 76  ion) any later v
00f0: 65 72 73 69 6f 6e 2e 0a 3b 0a 3b 20 54 68 69 73  ersion..;.; This
0100: 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73 74   program is dist
0110: 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20 68  ributed in the h
0120: 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c 6c  ope that it will
0130: 20 62 65 20 75 73 65 66 75 6c 2c 0a 3b 20 62 75   be useful,.; bu
0140: 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41  t WITHOUT ANY WA
0150: 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20  RRANTY; without 
0160: 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69 65 64  even the implied
0170: 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 3b 20 4d   warranty of.; M
0180: 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59 20 6f  ERCHANTABILITY o
0190: 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20 41 20  r FITNESS FOR A 
01a0: 50 41 52 54 49 43 55 4c 41 52 20 50 55 52 50 4f  PARTICULAR PURPO
01b0: 53 45 2e 20 20 53 65 65 20 74 68 65 0a 3b 20 47  SE.  See the.; G
01c0: 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69  NU General Publi
01d0: 63 20 4c 69 63 65 6e 73 65 20 66 6f 72 20 6d 6f  c License for mo
01e0: 72 65 20 64 65 74 61 69 6c 73 2e 0a 0a 3b 20 72  re details...; r
01f0: 65 76 69 73 65 64 20 44 65 63 65 6d 62 65 72 20  evised December 
0200: 32 30 31 30 20 74 6f 20 68 6f 6e 6f 72 20 6c 61  2010 to honor la
0210: 79 65 72 20 76 69 73 69 62 69 6c 69 74 79 0a 0a  yer visibility..
0220: 3b 3b 20 43 6f 6d 62 69 6e 65 20 65 61 63 68 20  ;; Combine each 
0230: 6c 61 79 65 72 20 6f 66 20 74 68 65 20 69 6d 61  layer of the ima
0240: 67 65 20 77 69 74 68 20 61 20 63 6f 70 79 20 6f  ge with a copy o
0250: 66 20 74 68 65 20 62 61 63 6b 67 72 6f 75 6e 64  f the background
0260: 20 6c 61 79 65 72 0a 0a 28 64 65 66 69 6e 65 20   layer..(define 
0270: 28 73 63 72 69 70 74 2d 66 75 2d 73 67 2d 61 6e  (script-fu-sg-an
0280: 69 6d 2d 63 6f 6d 62 69 6e 65 2d 62 61 63 6b 67  im-combine-backg
0290: 72 6f 75 6e 64 20 69 6d 61 67 65 29 0a 20 20 3b  round image).  ;
02a0: 20 67 65 74 20 76 69 73 69 62 6c 65 20 6c 61 79   get visible lay
02b0: 65 72 73 20 28 62 6f 74 74 6f 6d 2d 74 6f 2d 74  ers (bottom-to-t
02c0: 6f 70 29 0a 20 20 28 64 65 66 69 6e 65 20 28 67  op).  (define (g
02d0: 65 74 2d 76 69 73 69 62 6c 65 73 20 69 6d 61 67  et-visibles imag
02e0: 65 29 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70  e).    (let loop
02f0: 20 28 28 6c 61 79 65 72 73 20 28 76 65 63 74 6f   ((layers (vecto
0300: 72 2d 3e 6c 69 73 74 20 28 63 61 64 72 20 28 67  r->list (cadr (g
0310: 69 6d 70 2d 69 6d 61 67 65 2d 67 65 74 2d 6c 61  imp-image-get-la
0320: 79 65 72 73 20 69 6d 61 67 65 29 29 29 29 0a 20  yers image)))). 
0330: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 76                (v
0340: 69 73 69 62 6c 65 73 20 27 28 29 29 20 29 0a 20  isibles '()) ). 
0350: 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20       (if (null? 
0360: 6c 61 79 65 72 73 29 0a 20 20 20 20 20 20 20 20  layers).        
0370: 76 69 73 69 62 6c 65 73 0a 20 20 20 20 20 20 20  visibles.       
0380: 20 28 6c 6f 6f 70 20 28 63 64 72 20 6c 61 79 65   (loop (cdr laye
0390: 72 73 29 20 0a 20 20 20 20 20 20 20 20 20 20 20  rs) .           
03a0: 20 20 20 28 69 66 20 28 7a 65 72 6f 3f 20 28 63     (if (zero? (c
03b0: 61 72 20 28 67 69 6d 70 2d 64 72 61 77 61 62 6c  ar (gimp-drawabl
03c0: 65 2d 67 65 74 2d 76 69 73 69 62 6c 65 20 28 63  e-get-visible (c
03d0: 61 72 20 6c 61 79 65 72 73 29 29 29 29 0a 20 20  ar layers)))).  
03e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 69                vi
03f0: 73 69 62 6c 65 73 0a 20 20 20 20 20 20 20 20 20  sibles.         
0400: 20 20 20 20 20 20 20 28 63 6f 6e 73 20 28 63 61         (cons (ca
0410: 72 20 6c 61 79 65 72 73 29 20 76 69 73 69 62 6c  r layers) visibl
0420: 65 73 29 20 29 20 29 20 29 20 29 20 29 0a 20 20  es) ) ) ) ) ).  
0430: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0a 20                . 
0440: 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 75 6e 64   (gimp-image-und
0450: 6f 2d 67 72 6f 75 70 2d 73 74 61 72 74 20 69 6d  o-group-start im
0460: 61 67 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 6c  age).  (let* ((l
0470: 61 79 65 72 73 20 28 76 65 63 74 6f 72 2d 3e 6c  ayers (vector->l
0480: 69 73 74 20 28 63 61 64 72 20 28 67 69 6d 70 2d  ist (cadr (gimp-
0490: 69 6d 61 67 65 2d 67 65 74 2d 6c 61 79 65 72 73  image-get-layers
04a0: 20 69 6d 61 67 65 29 29 29 29 0a 20 20 20 20 20   image)))).     
04b0: 20 20 20 20 28 76 69 73 69 62 6c 65 73 20 28 67      (visibles (g
04c0: 65 74 2d 76 69 73 69 62 6c 65 73 20 69 6d 61 67  et-visibles imag
04d0: 65 29 29 0a 20 20 20 20 20 20 20 20 20 28 62 67  e)).         (bg
04e0: 2d 6c 61 79 65 72 20 28 63 61 72 20 28 6c 61 73  -layer (car (las
04f0: 74 20 6c 61 79 65 72 73 29 29 29 0a 20 20 20 20  t layers))).    
0500: 20 20 20 20 20 28 6f 72 69 67 2d 73 65 6c 20 28       (orig-sel (
0510: 63 61 72 20 28 67 69 6d 70 2d 73 65 6c 65 63 74  car (gimp-select
0520: 69 6f 6e 2d 73 61 76 65 20 69 6d 61 67 65 29 29  ion-save image))
0530: 29 20 29 0a 20 20 20 20 28 67 69 6d 70 2d 73 65  ) ).    (gimp-se
0540: 6c 65 63 74 69 6f 6e 2d 6e 6f 6e 65 20 69 6d 61  lection-none ima
0550: 67 65 29 0a 20 20 20 20 28 6d 61 70 20 28 6c 61  ge).    (map (la
0560: 6d 62 64 61 20 28 78 29 20 28 67 69 6d 70 2d 64  mbda (x) (gimp-d
0570: 72 61 77 61 62 6c 65 2d 73 65 74 2d 76 69 73 69  rawable-set-visi
0580: 62 6c 65 20 78 20 46 41 4c 53 45 29 29 20 76 69  ble x FALSE)) vi
0590: 73 69 62 6c 65 73 29 0a 20 20 20 20 28 77 68 65  sibles).    (whe
05a0: 6e 20 28 3d 20 28 63 61 72 20 76 69 73 69 62 6c  n (= (car visibl
05b0: 65 73 29 20 62 67 2d 6c 61 79 65 72 29 0a 20 20  es) bg-layer).  
05c0: 20 20 20 20 28 73 65 74 21 20 76 69 73 69 62 6c      (set! visibl
05d0: 65 73 20 28 63 64 72 20 76 69 73 69 62 6c 65 73  es (cdr visibles
05e0: 29 29 0a 20 20 20 20 20 20 28 67 69 6d 70 2d 64  )).      (gimp-d
05f0: 72 61 77 61 62 6c 65 2d 73 65 74 2d 76 69 73 69  rawable-set-visi
0600: 62 6c 65 20 62 67 2d 6c 61 79 65 72 20 54 52 55  ble bg-layer TRU
0610: 45 29 20 29 0a 20 20 20 20 28 77 68 69 6c 65 20  E) ).    (while 
0620: 28 70 61 69 72 3f 20 76 69 73 69 62 6c 65 73 29  (pair? visibles)
0630: 0a 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 6c  .      (let* ((l
0640: 61 79 65 72 20 28 63 61 72 20 76 69 73 69 62 6c  ayer (car visibl
0650: 65 73 29 29 0a 20 20 20 20 20 20 20 20 20 20 20  es)).           
0660: 20 20 28 70 6f 73 69 74 69 6f 6e 20 28 63 61 72    (position (car
0670: 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 67 65 74   (gimp-image-get
0680: 2d 6c 61 79 65 72 2d 70 6f 73 69 74 69 6f 6e 20  -layer-position 
0690: 69 6d 61 67 65 20 6c 61 79 65 72 29 29 29 20 0a  image layer))) .
06a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 62 61               (ba
06b0: 73 65 2d 6c 61 79 65 72 20 30 29 0a 20 20 20 20  se-layer 0).    
06c0: 20 20 20 20 20 20 20 20 20 28 6c 61 79 65 72 2d           (layer-
06d0: 6e 61 6d 65 20 22 22 29 20 29 0a 20 20 20 20 20  name "") ).     
06e0: 20 20 20 28 67 69 6d 70 2d 64 72 61 77 61 62 6c     (gimp-drawabl
06f0: 65 2d 73 65 74 2d 76 69 73 69 62 6c 65 20 28 63  e-set-visible (c
0700: 61 72 20 76 69 73 69 62 6c 65 73 29 20 54 52 55  ar visibles) TRU
0710: 45 29 0a 20 20 20 20 20 20 20 20 28 73 65 74 21  E).        (set!
0720: 20 6c 61 79 65 72 2d 6e 61 6d 65 20 28 63 61 72   layer-name (car
0730: 20 28 67 69 6d 70 2d 64 72 61 77 61 62 6c 65 2d   (gimp-drawable-
0740: 67 65 74 2d 6e 61 6d 65 20 6c 61 79 65 72 29 29  get-name layer))
0750: 29 0a 20 20 20 20 20 20 20 20 28 73 65 74 21 20  ).        (set! 
0760: 62 61 73 65 2d 6c 61 79 65 72 20 28 63 61 72 20  base-layer (car 
0770: 28 67 69 6d 70 2d 6c 61 79 65 72 2d 6e 65 77 2d  (gimp-layer-new-
0780: 66 72 6f 6d 2d 64 72 61 77 61 62 6c 65 20 62 67  from-drawable bg
0790: 2d 6c 61 79 65 72 20 69 6d 61 67 65 29 29 29 0a  -layer image))).
07a0: 20 20 20 20 20 20 20 20 28 67 69 6d 70 2d 69 6d          (gimp-im
07b0: 61 67 65 2d 61 64 64 2d 6c 61 79 65 72 20 69 6d  age-add-layer im
07c0: 61 67 65 20 62 61 73 65 2d 6c 61 79 65 72 20 28  age base-layer (
07d0: 2b 20 70 6f 73 69 74 69 6f 6e 20 31 29 29 0a 20  + position 1)). 
07e0: 20 20 20 20 20 20 20 28 67 69 6d 70 2d 64 72 61         (gimp-dra
07f0: 77 61 62 6c 65 2d 73 65 74 2d 76 69 73 69 62 6c  wable-set-visibl
0800: 65 20 62 61 73 65 2d 6c 61 79 65 72 20 54 52 55  e base-layer TRU
0810: 45 29 0a 20 20 20 20 20 20 20 20 28 73 65 74 21  E).        (set!
0820: 20 62 61 73 65 2d 6c 61 79 65 72 20 28 63 61 72   base-layer (car
0830: 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 6d 65 72   (gimp-image-mer
0840: 67 65 2d 64 6f 77 6e 20 69 6d 61 67 65 20 6c 61  ge-down image la
0850: 79 65 72 20 43 4c 49 50 2d 54 4f 2d 42 4f 54 54  yer CLIP-TO-BOTT
0860: 4f 4d 2d 4c 41 59 45 52 29 29 29 0a 20 20 20 20  OM-LAYER))).    
0870: 20 20 20 20 28 67 69 6d 70 2d 64 72 61 77 61 62      (gimp-drawab
0880: 6c 65 2d 73 65 74 2d 6e 61 6d 65 20 62 61 73 65  le-set-name base
0890: 2d 6c 61 79 65 72 20 6c 61 79 65 72 2d 6e 61 6d  -layer layer-nam
08a0: 65 29 20 29 0a 20 20 20 20 20 20 28 73 65 74 21  e) ).      (set!
08b0: 20 76 69 73 69 62 6c 65 73 20 28 63 64 72 20 76   visibles (cdr v
08c0: 69 73 69 62 6c 65 73 29 29 20 29 0a 20 20 20 20  isibles)) ).    
08d0: 28 67 69 6d 70 2d 73 65 6c 65 63 74 69 6f 6e 2d  (gimp-selection-
08e0: 6c 6f 61 64 20 6f 72 69 67 2d 73 65 6c 29 0a 20  load orig-sel). 
08f0: 20 20 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 72     (gimp-image-r
0900: 65 6d 6f 76 65 2d 63 68 61 6e 6e 65 6c 20 69 6d  emove-channel im
0910: 61 67 65 20 6f 72 69 67 2d 73 65 6c 29 20 29 0a  age orig-sel) ).
0920: 20 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 75 6e    (gimp-image-un
0930: 64 6f 2d 67 72 6f 75 70 2d 65 6e 64 20 69 6d 61  do-group-end ima
0940: 67 65 29 0a 20 20 28 67 69 6d 70 2d 64 69 73 70  ge).  (gimp-disp
0950: 6c 61 79 73 2d 66 6c 75 73 68 29 0a 20 20 29 0a  lays-flush).  ).
0960: 0a 28 73 63 72 69 70 74 2d 66 75 2d 72 65 67 69  .(script-fu-regi
0970: 73 74 65 72 20 22 73 63 72 69 70 74 2d 66 75 2d  ster "script-fu-
0980: 73 67 2d 61 6e 69 6d 2d 63 6f 6d 62 69 6e 65 2d  sg-anim-combine-
0990: 62 61 63 6b 67 72 6f 75 6e 64 22 0a 20 20 22 3c  background".  "<
09a0: 49 6d 61 67 65 3e 2f 46 69 6c 74 65 72 73 2f 41  Image>/Filters/A
09b0: 6e 69 6d 61 74 69 6f 6e 2f 5f 43 6f 6d 62 69 6e  nimation/_Combin
09c0: 65 20 62 61 63 6b 67 72 6f 75 6e 64 22 0a 20 20  e background".  
09d0: 22 43 6f 6d 62 69 6e 65 20 65 61 63 68 20 6c 61  "Combine each la
09e0: 79 65 72 20 6f 66 20 74 68 65 20 69 6d 61 67 65  yer of the image
09f0: 20 77 69 74 68 20 61 20 63 6f 70 79 20 6f 66 20   with a copy of 
0a00: 74 68 65 20 62 61 63 6b 67 72 6f 75 6e 64 20 6c  the background l
0a10: 61 79 65 72 22 0a 20 20 22 53 61 75 6c 20 47 6f  ayer".  "Saul Go
0a20: 6f 64 65 22 0a 20 20 22 53 61 75 6c 20 47 6f 6f  ode".  "Saul Goo
0a30: 64 65 22 0a 20 20 22 34 2f 32 32 2f 32 30 30 37  de".  "4/22/2007
0a40: 22 0a 20 20 22 2a 22 0a 20 20 53 46 2d 49 4d 41  ".  "*".  SF-IMA
0a50: 47 45 20 20 20 20 22 49 6d 61 67 65 22 20 20 20  GE    "Image"   
0a60: 20 30 0a 20 20 29 0a 0a 3b 3b 20 4f 76 65 72 6c   0.  )..;; Overl
0a70: 61 79 20 65 61 63 68 20 6c 61 79 65 72 20 6f 66  ay each layer of
0a80: 20 74 68 65 20 69 6d 61 67 65 20 77 69 74 68 20   the image with 
0a90: 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 62 61  a copy of the ba
0aa0: 63 6b 67 72 6f 75 6e 64 20 6c 61 79 65 72 0a 0a  ckground layer..
0ab0: 28 64 65 66 69 6e 65 20 28 73 63 72 69 70 74 2d  (define (script-
0ac0: 66 75 2d 73 67 2d 61 6e 69 6d 2d 6f 76 65 72 6c  fu-sg-anim-overl
0ad0: 61 79 2d 62 61 63 6b 67 72 6f 75 6e 64 20 69 6d  ay-background im
0ae0: 61 67 65 29 0a 20 20 3b 20 67 65 74 20 76 69 73  age).  ; get vis
0af0: 69 62 6c 65 20 6c 61 79 65 72 73 20 28 62 6f 74  ible layers (bot
0b00: 74 6f 6d 2d 74 6f 2d 74 6f 70 29 0a 20 20 28 64  tom-to-top).  (d
0b10: 65 66 69 6e 65 20 28 67 65 74 2d 76 69 73 69 62  efine (get-visib
0b20: 6c 65 73 20 69 6d 61 67 65 29 0a 20 20 20 20 28  les image).    (
0b30: 6c 65 74 20 6c 6f 6f 70 20 28 28 6c 61 79 65 72  let loop ((layer
0b40: 73 20 28 76 65 63 74 6f 72 2d 3e 6c 69 73 74 20  s (vector->list 
0b50: 28 63 61 64 72 20 28 67 69 6d 70 2d 69 6d 61 67  (cadr (gimp-imag
0b60: 65 2d 67 65 74 2d 6c 61 79 65 72 73 20 69 6d 61  e-get-layers ima
0b70: 67 65 29 29 29 29 0a 20 20 20 20 20 20 20 20 20  ge)))).         
0b80: 20 20 20 20 20 20 28 76 69 73 69 62 6c 65 73 20        (visibles 
0b90: 27 28 29 29 20 29 0a 20 20 20 20 20 20 28 69 66  '()) ).      (if
0ba0: 20 28 6e 75 6c 6c 3f 20 6c 61 79 65 72 73 29 0a   (null? layers).
0bb0: 20 20 20 20 20 20 20 20 76 69 73 69 62 6c 65 73          visibles
0bc0: 0a 20 20 20 20 20 20 20 20 28 6c 6f 6f 70 20 28  .        (loop (
0bd0: 63 64 72 20 6c 61 79 65 72 73 29 20 0a 20 20 20  cdr layers) .   
0be0: 20 20 20 20 20 20 20 20 20 20 20 28 69 66 20 28             (if (
0bf0: 7a 65 72 6f 3f 20 28 63 61 72 20 28 67 69 6d 70  zero? (car (gimp
0c00: 2d 64 72 61 77 61 62 6c 65 2d 67 65 74 2d 76 69  -drawable-get-vi
0c10: 73 69 62 6c 65 20 28 63 61 72 20 6c 61 79 65 72  sible (car layer
0c20: 73 29 29 29 29 0a 20 20 20 20 20 20 20 20 20 20  s)))).          
0c30: 20 20 20 20 20 20 76 69 73 69 62 6c 65 73 0a 20        visibles. 
0c40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28                 (
0c50: 63 6f 6e 73 20 28 63 61 72 20 6c 61 79 65 72 73  cons (car layers
0c60: 29 20 76 69 73 69 62 6c 65 73 29 20 29 20 29 20  ) visibles) ) ) 
0c70: 29 20 29 20 29 0a 20 20 28 67 69 6d 70 2d 69 6d  ) ) ).  (gimp-im
0c80: 61 67 65 2d 75 6e 64 6f 2d 67 72 6f 75 70 2d 73  age-undo-group-s
0c90: 74 61 72 74 20 69 6d 61 67 65 29 0a 20 20 28 6c  tart image).  (l
0ca0: 65 74 2a 20 28 28 6c 61 79 65 72 73 20 28 76 65  et* ((layers (ve
0cb0: 63 74 6f 72 2d 3e 6c 69 73 74 20 28 63 61 64 72  ctor->list (cadr
0cc0: 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 67 65 74   (gimp-image-get
0cd0: 2d 6c 61 79 65 72 73 20 69 6d 61 67 65 29 29 29  -layers image)))
0ce0: 29 0a 20 20 20 20 20 20 20 20 20 28 76 69 73 69  ).         (visi
0cf0: 62 6c 65 73 20 28 67 65 74 2d 76 69 73 69 62 6c  bles (get-visibl
0d00: 65 73 20 69 6d 61 67 65 29 29 0a 20 20 20 20 20  es image)).     
0d10: 20 20 20 20 28 62 67 2d 6c 61 79 65 72 20 28 63      (bg-layer (c
0d20: 61 72 20 28 6c 61 73 74 20 6c 61 79 65 72 73 29  ar (last layers)
0d30: 29 29 0a 20 20 20 20 20 20 20 20 20 28 6f 72 69  )).         (ori
0d40: 67 2d 73 65 6c 20 28 63 61 72 20 28 67 69 6d 70  g-sel (car (gimp
0d50: 2d 73 65 6c 65 63 74 69 6f 6e 2d 73 61 76 65 20  -selection-save 
0d60: 69 6d 61 67 65 29 29 29 20 29 0a 20 20 20 20 28  image))) ).    (
0d70: 67 69 6d 70 2d 73 65 6c 65 63 74 69 6f 6e 2d 6e  gimp-selection-n
0d80: 6f 6e 65 20 69 6d 61 67 65 29 0a 20 20 20 20 28  one image).    (
0d90: 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 78 29 20  map (lambda (x) 
0da0: 28 67 69 6d 70 2d 64 72 61 77 61 62 6c 65 2d 73  (gimp-drawable-s
0db0: 65 74 2d 76 69 73 69 62 6c 65 20 78 20 46 41 4c  et-visible x FAL
0dc0: 53 45 29 29 20 76 69 73 69 62 6c 65 73 29 0a 20  SE)) visibles). 
0dd0: 20 20 20 28 77 68 65 6e 20 28 3d 20 28 63 61 72     (when (= (car
0de0: 20 76 69 73 69 62 6c 65 73 29 20 62 67 2d 6c 61   visibles) bg-la
0df0: 79 65 72 29 0a 20 20 20 20 20 20 28 73 65 74 21  yer).      (set!
0e00: 20 76 69 73 69 62 6c 65 73 20 28 63 64 72 20 76   visibles (cdr v
0e10: 69 73 69 62 6c 65 73 29 29 0a 20 20 20 20 20 20  isibles)).      
0e20: 28 67 69 6d 70 2d 64 72 61 77 61 62 6c 65 2d 73  (gimp-drawable-s
0e30: 65 74 2d 76 69 73 69 62 6c 65 20 62 67 2d 6c 61  et-visible bg-la
0e40: 79 65 72 20 54 52 55 45 29 20 29 0a 20 20 20 20  yer TRUE) ).    
0e50: 28 77 68 69 6c 65 20 28 70 61 69 72 3f 20 76 69  (while (pair? vi
0e60: 73 69 62 6c 65 73 29 0a 20 20 20 20 20 20 28 6c  sibles).      (l
0e70: 65 74 2a 20 28 28 6c 61 79 65 72 20 28 63 61 72  et* ((layer (car
0e80: 20 76 69 73 69 62 6c 65 73 29 29 0a 20 20 20 20   visibles)).    
0e90: 20 20 20 20 20 20 20 20 20 28 70 6f 73 69 74 69           (positi
0ea0: 6f 6e 20 28 63 61 72 20 28 67 69 6d 70 2d 69 6d  on (car (gimp-im
0eb0: 61 67 65 2d 67 65 74 2d 6c 61 79 65 72 2d 70 6f  age-get-layer-po
0ec0: 73 69 74 69 6f 6e 20 69 6d 61 67 65 20 6c 61 79  sition image lay
0ed0: 65 72 29 29 29 20 0a 20 20 20 20 20 20 20 20 20  er))) .         
0ee0: 20 20 20 20 28 6f 76 65 72 2d 6c 61 79 65 72 20      (over-layer 
0ef0: 30 29 20 29 0a 20 20 20 20 20 20 20 20 28 67 69  0) ).        (gi
0f00: 6d 70 2d 64 72 61 77 61 62 6c 65 2d 73 65 74 2d  mp-drawable-set-
0f10: 76 69 73 69 62 6c 65 20 6c 61 79 65 72 20 54 52  visible layer TR
0f20: 55 45 29 0a 20 20 20 20 20 20 20 20 28 67 69 6d  UE).        (gim
0f30: 70 2d 69 6d 61 67 65 2d 73 65 74 2d 61 63 74 69  p-image-set-acti
0f40: 76 65 2d 6c 61 79 65 72 20 69 6d 61 67 65 20 6c  ve-layer image l
0f50: 61 79 65 72 29 0a 20 20 20 20 20 20 20 20 28 73  ayer).        (s
0f60: 65 74 21 20 6f 76 65 72 2d 6c 61 79 65 72 20 28  et! over-layer (
0f70: 63 61 72 20 28 67 69 6d 70 2d 6c 61 79 65 72 2d  car (gimp-layer-
0f80: 6e 65 77 2d 66 72 6f 6d 2d 64 72 61 77 61 62 6c  new-from-drawabl
0f90: 65 20 62 67 2d 6c 61 79 65 72 20 69 6d 61 67 65  e bg-layer image
0fa0: 29 29 29 0a 20 20 20 20 20 20 20 20 28 67 69 6d  ))).        (gim
0fb0: 70 2d 69 6d 61 67 65 2d 61 64 64 2d 6c 61 79 65  p-image-add-laye
0fc0: 72 20 69 6d 61 67 65 20 6f 76 65 72 2d 6c 61 79  r image over-lay
0fd0: 65 72 20 2d 31 29 0a 20 20 20 20 20 20 20 20 28  er -1).        (
0fe0: 67 69 6d 70 2d 64 72 61 77 61 62 6c 65 2d 73 65  gimp-drawable-se
0ff0: 74 2d 76 69 73 69 62 6c 65 20 6f 76 65 72 2d 6c  t-visible over-l
1000: 61 79 65 72 20 54 52 55 45 29 0a 20 20 20 20 20  ayer TRUE).     
1010: 20 20 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 6d     (gimp-image-m
1020: 65 72 67 65 2d 64 6f 77 6e 20 69 6d 61 67 65 20  erge-down image 
1030: 6f 76 65 72 2d 6c 61 79 65 72 20 45 58 50 41 4e  over-layer EXPAN
1040: 44 2d 41 53 2d 4e 45 43 45 53 53 41 52 59 29 20  D-AS-NECESSARY) 
1050: 29 0a 20 20 20 20 20 20 28 73 65 74 21 20 76 69  ).      (set! vi
1060: 73 69 62 6c 65 73 20 28 63 64 72 20 76 69 73 69  sibles (cdr visi
1070: 62 6c 65 73 29 29 20 29 0a 20 20 20 20 28 67 69  bles)) ).    (gi
1080: 6d 70 2d 73 65 6c 65 63 74 69 6f 6e 2d 6c 6f 61  mp-selection-loa
1090: 64 20 6f 72 69 67 2d 73 65 6c 29 0a 20 20 20 20  d orig-sel).    
10a0: 28 67 69 6d 70 2d 69 6d 61 67 65 2d 72 65 6d 6f  (gimp-image-remo
10b0: 76 65 2d 63 68 61 6e 6e 65 6c 20 69 6d 61 67 65  ve-channel image
10c0: 20 6f 72 69 67 2d 73 65 6c 29 20 29 0a 20 20 28   orig-sel) ).  (
10d0: 67 69 6d 70 2d 69 6d 61 67 65 2d 75 6e 64 6f 2d  gimp-image-undo-
10e0: 67 72 6f 75 70 2d 65 6e 64 20 69 6d 61 67 65 29  group-end image)
10f0: 0a 20 20 28 67 69 6d 70 2d 64 69 73 70 6c 61 79  .  (gimp-display
1100: 73 2d 66 6c 75 73 68 29 0a 20 20 29 0a 0a 28 73  s-flush).  )..(s
1110: 63 72 69 70 74 2d 66 75 2d 72 65 67 69 73 74 65  cript-fu-registe
1120: 72 20 22 73 63 72 69 70 74 2d 66 75 2d 73 67 2d  r "script-fu-sg-
1130: 61 6e 69 6d 2d 6f 76 65 72 6c 61 79 2d 62 61 63  anim-overlay-bac
1140: 6b 67 72 6f 75 6e 64 22 0a 20 20 22 3c 49 6d 61  kground".  "<Ima
1150: 67 65 3e 2f 46 69 6c 74 65 72 73 2f 41 6e 69 6d  ge>/Filters/Anim
1160: 61 74 69 6f 6e 2f 5f 4f 76 65 72 6c 61 79 20 62  ation/_Overlay b
1170: 61 63 6b 67 72 6f 75 6e 64 22 0a 20 20 22 4f 76  ackground".  "Ov
1180: 65 72 6c 61 79 20 65 61 63 68 20 6c 61 79 65 72  erlay each layer
1190: 20 6f 66 20 74 68 65 20 69 6d 61 67 65 20 77 69   of the image wi
11a0: 74 68 20 61 20 63 6f 70 79 20 6f 66 20 74 68 65  th a copy of the
11b0: 20 62 61 63 6b 67 72 6f 75 6e 64 20 6c 61 79 65   background laye
11c0: 72 22 0a 20 20 22 53 61 75 6c 20 47 6f 6f 64 65  r".  "Saul Goode
11d0: 22 0a 20 20 22 53 61 75 6c 20 47 6f 6f 64 65 22  ".  "Saul Goode"
11e0: 0a 20 20 22 34 2f 32 32 2f 32 30 30 37 22 0a 20  .  "4/22/2007". 
11f0: 20 22 2a 22 0a 20 20 53 46 2d 49 4d 41 47 45 20   "*".  SF-IMAGE 
1200: 20 20 20 22 49 6d 61 67 65 22 20 20 20 20 30 0a     "Image"    0.
1210: 20 20 29 0a                                        ).