GIMP Script-fu

Hex Artifact Content
Login

Artifact c3aadbc1adb357f02843e9f276546ccae33d3beb:


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 28 64 65  re details...(de
01f0: 66 69 6e 65 20 28 73 63 72 69 70 74 2d 66 75 2d  fine (script-fu-
0200: 73 67 2d 74 6f 6f 6e 69 6e 61 74 6f 72 20 69 6d  sg-tooninator im
0210: 61 67 65 20 64 72 61 77 61 62 6c 65 29 0a 20 20  age drawable).  
0220: 28 75 6e 6c 65 73 73 20 28 7a 65 72 6f 3f 20 28  (unless (zero? (
0230: 63 61 72 20 28 67 69 6d 70 2d 64 72 61 77 61 62  car (gimp-drawab
0240: 6c 65 2d 69 73 2d 6c 61 79 65 72 20 64 72 61 77  le-is-layer draw
0250: 61 62 6c 65 29 29 29 0a 20 20 20 20 28 67 69 6d  able))).    (gim
0260: 70 2d 69 6d 61 67 65 2d 75 6e 64 6f 2d 67 72 6f  p-image-undo-gro
0270: 75 70 2d 73 74 61 72 74 20 69 6d 61 67 65 29 0a  up-start image).
0280: 20 20 20 20 28 6c 65 74 20 28 28 67 72 61 79 2d      (let ((gray-
0290: 6d 6f 64 65 3f 20 28 3d 20 28 63 61 72 20 28 67  mode? (= (car (g
02a0: 69 6d 70 2d 69 6d 61 67 65 2d 62 61 73 65 2d 74  imp-image-base-t
02b0: 79 70 65 20 69 6d 61 67 65 29 29 20 31 29 29 0a  ype image)) 1)).
02c0: 20 20 20 20 20 20 20 20 20 20 28 72 65 74 69 6e            (retin
02d0: 65 78 2d 6c 61 79 65 72 20 30 29 0a 20 20 20 20  ex-layer 0).    
02e0: 20 20 20 20 20 20 28 65 64 67 65 2d 6c 61 79 65        (edge-laye
02f0: 72 20 30 29 20 29 0a 20 20 20 20 20 20 28 69 66  r 0) ).      (if
0300: 20 67 72 61 79 2d 6d 6f 64 65 3f 0a 20 20 20 20   gray-mode?.    
0310: 20 20 20 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d      (gimp-image-
0320: 63 6f 6e 76 65 72 74 2d 72 67 62 20 69 6d 61 67  convert-rgb imag
0330: 65 29 20 29 0a 20 20 20 20 20 20 28 73 65 74 21  e) ).      (set!
0340: 20 72 65 74 69 6e 65 78 2d 6c 61 79 65 72 20 28   retinex-layer (
0350: 63 61 72 20 28 67 69 6d 70 2d 6c 61 79 65 72 2d  car (gimp-layer-
0360: 63 6f 70 79 20 64 72 61 77 61 62 6c 65 20 54 52  copy drawable TR
0370: 55 45 29 29 29 0a 20 20 20 20 20 20 28 67 69 6d  UE))).      (gim
0380: 70 2d 64 72 61 77 61 62 6c 65 2d 73 65 74 2d 6e  p-drawable-set-n
0390: 61 6d 65 20 72 65 74 69 6e 65 78 2d 6c 61 79 65  ame retinex-laye
03a0: 72 20 22 52 65 74 69 6e 65 78 22 29 0a 20 20 20  r "Retinex").   
03b0: 20 20 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 61     (gimp-image-a
03c0: 64 64 2d 6c 61 79 65 72 20 69 6d 61 67 65 20 72  dd-layer image r
03d0: 65 74 69 6e 65 78 2d 6c 61 79 65 72 20 2d 31 29  etinex-layer -1)
03e0: 0a 20 20 20 20 20 20 28 70 6c 75 67 2d 69 6e 2d  .      (plug-in-
03f0: 72 65 74 69 6e 65 78 20 52 55 4e 2d 4e 4f 4e 49  retinex RUN-NONI
0400: 4e 54 45 52 41 43 54 49 56 45 20 69 6d 61 67 65  NTERACTIVE image
0410: 20 72 65 74 69 6e 65 78 2d 6c 61 79 65 72 20 31   retinex-layer 1
0420: 36 20 33 20 30 20 30 2e 31 29 0a 20 20 20 20 20  6 3 0 0.1).     
0430: 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 73 65 74   (gimp-image-set
0440: 2d 61 63 74 69 76 65 2d 6c 61 79 65 72 20 69 6d  -active-layer im
0450: 61 67 65 20 72 65 74 69 6e 65 78 2d 6c 61 79 65  age retinex-laye
0460: 72 29 0a 20 20 20 20 20 20 28 67 69 6d 70 2d 6c  r).      (gimp-l
0470: 61 79 65 72 2d 73 65 74 2d 6d 6f 64 65 20 72 65  ayer-set-mode re
0480: 74 69 6e 65 78 2d 6c 61 79 65 72 20 56 41 4c 55  tinex-layer VALU
0490: 45 2d 4d 4f 44 45 29 0a 20 20 20 20 20 20 28 73  E-MODE).      (s
04a0: 65 74 21 20 65 64 67 65 2d 6c 61 79 65 72 20 28  et! edge-layer (
04b0: 63 61 72 20 28 67 69 6d 70 2d 6c 61 79 65 72 2d  car (gimp-layer-
04c0: 63 6f 70 79 20 64 72 61 77 61 62 6c 65 20 54 52  copy drawable TR
04d0: 55 45 29 29 29 0a 20 20 20 20 20 20 28 67 69 6d  UE))).      (gim
04e0: 70 2d 64 72 61 77 61 62 6c 65 2d 73 65 74 2d 6e  p-drawable-set-n
04f0: 61 6d 65 20 65 64 67 65 2d 6c 61 79 65 72 20 22  ame edge-layer "
0500: 45 64 67 65 73 22 29 0a 20 20 20 20 20 20 28 67  Edges").      (g
0510: 69 6d 70 2d 69 6d 61 67 65 2d 61 64 64 2d 6c 61  imp-image-add-la
0520: 79 65 72 20 69 6d 61 67 65 20 65 64 67 65 2d 6c  yer image edge-l
0530: 61 79 65 72 20 2d 31 29 0a 20 20 20 20 20 20 28  ayer -1).      (
0540: 6c 65 74 20 28 28 72 65 74 69 6e 65 78 2d 6d 61  let ((retinex-ma
0550: 73 6b 20 28 63 61 72 20 28 67 69 6d 70 2d 6c 61  sk (car (gimp-la
0560: 79 65 72 2d 63 72 65 61 74 65 2d 6d 61 73 6b 20  yer-create-mask 
0570: 72 65 74 69 6e 65 78 2d 6c 61 79 65 72 20 30 29  retinex-layer 0)
0580: 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 28  )).            (
0590: 62 75 66 66 65 72 20 28 63 61 72 20 28 67 69 6d  buffer (car (gim
05a0: 70 2d 65 64 69 74 2d 6e 61 6d 65 64 2d 63 6f 70  p-edit-named-cop
05b0: 79 20 64 72 61 77 61 62 6c 65 20 22 6f 72 69 67  y drawable "orig
05c0: 22 29 29 29 20 29 0a 20 20 20 20 20 20 20 20 28  "))) ).        (
05d0: 67 69 6d 70 2d 6c 61 79 65 72 2d 61 64 64 2d 6d  gimp-layer-add-m
05e0: 61 73 6b 20 72 65 74 69 6e 65 78 2d 6c 61 79 65  ask retinex-laye
05f0: 72 20 72 65 74 69 6e 65 78 2d 6d 61 73 6b 29 0a  r retinex-mask).
0600: 20 20 20 20 20 20 20 20 28 67 69 6d 70 2d 66 6c          (gimp-fl
0610: 6f 61 74 69 6e 67 2d 73 65 6c 2d 61 6e 63 68 6f  oating-sel-ancho
0620: 72 20 28 63 61 72 20 28 67 69 6d 70 2d 65 64 69  r (car (gimp-edi
0630: 74 2d 6e 61 6d 65 64 2d 70 61 73 74 65 20 72 65  t-named-paste re
0640: 74 69 6e 65 78 2d 6d 61 73 6b 20 62 75 66 66 65  tinex-mask buffe
0650: 72 20 54 52 55 45 29 29 29 0a 20 20 20 20 20 20  r TRUE))).      
0660: 20 20 28 67 69 6d 70 2d 74 68 72 65 73 68 6f 6c    (gimp-threshol
0670: 64 20 72 65 74 69 6e 65 78 2d 6d 61 73 6b 20 33  d retinex-mask 3
0680: 36 20 32 35 35 29 20 29 0a 20 20 20 20 20 20 28  6 255) ).      (
0690: 6c 65 74 20 28 28 74 65 6d 70 2d 6c 61 79 65 72  let ((temp-layer
06a0: 20 28 63 61 72 20 28 67 69 6d 70 2d 6c 61 79 65   (car (gimp-laye
06b0: 72 2d 63 6f 70 79 20 72 65 74 69 6e 65 78 2d 6c  r-copy retinex-l
06c0: 61 79 65 72 20 54 52 55 45 29 29 29 29 0a 20 20  ayer TRUE)))).  
06d0: 20 20 20 20 20 20 28 67 69 6d 70 2d 69 6d 61 67        (gimp-imag
06e0: 65 2d 73 65 74 2d 61 63 74 69 76 65 2d 6c 61 79  e-set-active-lay
06f0: 65 72 20 69 6d 61 67 65 20 65 64 67 65 2d 6c 61  er image edge-la
0700: 79 65 72 29 0a 20 20 20 20 20 20 20 20 28 67 69  yer).        (gi
0710: 6d 70 2d 69 6d 61 67 65 2d 61 64 64 2d 6c 61 79  mp-image-add-lay
0720: 65 72 20 69 6d 61 67 65 20 74 65 6d 70 2d 6c 61  er image temp-la
0730: 79 65 72 20 2d 31 29 0a 20 20 20 20 20 20 20 20  yer -1).        
0740: 28 73 65 74 21 20 65 64 67 65 2d 6c 61 79 65 72  (set! edge-layer
0750: 20 28 63 61 72 20 28 67 69 6d 70 2d 69 6d 61 67   (car (gimp-imag
0760: 65 2d 6d 65 72 67 65 2d 64 6f 77 6e 20 69 6d 61  e-merge-down ima
0770: 67 65 20 74 65 6d 70 2d 6c 61 79 65 72 20 45 58  ge temp-layer EX
0780: 50 41 4e 44 2d 41 53 2d 4e 45 43 45 53 53 41 52  PAND-AS-NECESSAR
0790: 59 29 29 29 20 29 0a 20 20 20 20 20 20 28 70 6c  Y))) ).      (pl
07a0: 75 67 2d 69 6e 2d 67 61 75 73 73 20 52 55 4e 2d  ug-in-gauss RUN-
07b0: 4e 4f 4e 49 4e 54 45 52 41 43 54 49 56 45 20 69  NONINTERACTIVE i
07c0: 6d 61 67 65 20 65 64 67 65 2d 6c 61 79 65 72 20  mage edge-layer 
07d0: 32 2e 30 20 32 2e 30 20 30 29 0a 20 20 20 20 20  2.0 2.0 0).     
07e0: 20 28 70 6c 75 67 2d 69 6e 2d 67 61 75 73 73 20   (plug-in-gauss 
07f0: 52 55 4e 2d 4e 4f 4e 49 4e 54 45 52 41 43 54 49  RUN-NONINTERACTI
0800: 56 45 20 69 6d 61 67 65 20 65 64 67 65 2d 6c 61  VE image edge-la
0810: 79 65 72 20 32 2e 30 20 32 2e 30 20 30 29 0a 20  yer 2.0 2.0 0). 
0820: 20 20 20 20 20 28 70 6c 75 67 2d 69 6e 2d 6c 61       (plug-in-la
0830: 70 6c 61 63 65 20 52 55 4e 2d 4e 4f 4e 49 4e 54  place RUN-NONINT
0840: 45 52 41 43 54 49 56 45 20 69 6d 61 67 65 20 65  ERACTIVE image e
0850: 64 67 65 2d 6c 61 79 65 72 29 0a 20 20 20 20 20  dge-layer).     
0860: 20 28 70 6c 75 67 2d 69 6e 2d 64 65 73 70 65 63   (plug-in-despec
0870: 6b 6c 65 20 52 55 4e 2d 4e 4f 4e 49 4e 54 45 52  kle RUN-NONINTER
0880: 41 43 54 49 56 45 20 69 6d 61 67 65 20 65 64 67  ACTIVE image edg
0890: 65 2d 6c 61 79 65 72 20 31 20 31 20 30 20 32 35  e-layer 1 1 0 25
08a0: 35 29 0a 20 20 20 20 20 20 28 77 68 65 6e 20 28  5).      (when (
08b0: 7a 65 72 6f 3f 20 28 63 61 72 20 28 67 69 6d 70  zero? (car (gimp
08c0: 2d 73 65 6c 65 63 74 69 6f 6e 2d 69 73 2d 65 6d  -selection-is-em
08d0: 70 74 79 20 69 6d 61 67 65 29 29 29 0a 20 20 20  pty image))).   
08e0: 20 20 20 20 20 20 28 67 69 6d 70 2d 73 65 6c 65        (gimp-sele
08f0: 63 74 69 6f 6e 2d 69 6e 76 65 72 74 20 69 6d 61  ction-invert ima
0900: 67 65 29 0a 20 20 20 20 20 20 20 20 20 28 67 69  ge).         (gi
0910: 6d 70 2d 65 64 69 74 2d 63 6c 65 61 72 20 65 64  mp-edit-clear ed
0920: 67 65 2d 6c 61 79 65 72 29 0a 20 20 20 20 20 20  ge-layer).      
0930: 20 20 20 28 67 69 6d 70 2d 65 64 69 74 2d 63 6c     (gimp-edit-cl
0940: 65 61 72 20 72 65 74 69 6e 65 78 2d 6c 61 79 65  ear retinex-laye
0950: 72 29 0a 20 20 20 20 20 20 20 20 20 28 67 69 6d  r).         (gim
0960: 70 2d 73 65 6c 65 63 74 69 6f 6e 2d 69 6e 76 65  p-selection-inve
0970: 72 74 20 69 6d 61 67 65 29 20 29 0a 20 20 20 20  rt image) ).    
0980: 20 20 28 69 66 20 67 72 61 79 2d 6d 6f 64 65 3f    (if gray-mode?
0990: 0a 20 20 20 20 20 20 20 20 28 67 69 6d 70 2d 69  .        (gimp-i
09a0: 6d 61 67 65 2d 63 6f 6e 76 65 72 74 2d 67 72 61  mage-convert-gra
09b0: 79 73 63 61 6c 65 20 69 6d 61 67 65 29 20 29 29  yscale image) ))
09c0: 0a 20 20 20 20 28 67 69 6d 70 2d 69 6d 61 67 65  .    (gimp-image
09d0: 2d 75 6e 64 6f 2d 67 72 6f 75 70 2d 65 6e 64 20  -undo-group-end 
09e0: 69 6d 61 67 65 29 20 29 0a 20 20 28 67 69 6d 70  image) ).  (gimp
09f0: 2d 64 69 73 70 6c 61 79 73 2d 66 6c 75 73 68 29  -displays-flush)
0a00: 0a 20 20 29 0a 20 20 20 20 20 20 20 20 0a 28 73  .  ).        .(s
0a10: 63 72 69 70 74 2d 66 75 2d 72 65 67 69 73 74 65  cript-fu-registe
0a20: 72 20 22 73 63 72 69 70 74 2d 66 75 2d 73 67 2d  r "script-fu-sg-
0a30: 74 6f 6f 6e 69 6e 61 74 6f 72 22 0a 20 20 22 54  tooninator".  "T
0a40: 6f 6f 6e 2d 69 6e 61 74 6f 72 22 0a 20 20 22 43  oon-inator".  "C
0a50: 72 65 61 74 65 20 74 77 6f 20 61 64 6a 75 76 61  reate two adjuva
0a60: 6e 74 20 6c 61 79 65 72 73 20 77 68 69 63 68 20  nt layers which 
0a70: 72 65 73 75 6c 74 20 69 6e 20 61 20 63 61 72 74  result in a cart
0a80: 6f 6f 6e 2d 6c 69 6b 65 20 61 70 70 65 61 72 61  oon-like appeara
0a90: 6e 63 65 22 0a 20 20 22 53 61 75 6c 20 47 6f 6f  nce".  "Saul Goo
0aa0: 64 65 22 0a 20 20 22 53 61 75 6c 20 47 6f 6f 64  de".  "Saul Good
0ab0: 65 22 0a 20 20 22 53 65 70 74 20 32 30 31 31 22  e".  "Sept 2011"
0ac0: 0a 20 20 22 52 47 42 2a 2c 47 52 41 59 2a 22 0a  .  "RGB*,GRAY*".
0ad0: 20 20 53 46 2d 49 4d 41 47 45 20 20 20 20 22 49    SF-IMAGE    "I
0ae0: 6d 61 67 65 22 20 20 20 20 30 0a 20 20 53 46 2d  mage"    0.  SF-
0af0: 44 52 41 57 41 42 4c 45 20 22 4c 61 79 65 72 22  DRAWABLE "Layer"
0b00: 20 30 0a 20 20 29 0a 0a 28 73 63 72 69 70 74 2d   0.  )..(script-
0b10: 66 75 2d 6d 65 6e 75 2d 72 65 67 69 73 74 65 72  fu-menu-register
0b20: 20 22 73 63 72 69 70 74 2d 66 75 2d 73 67 2d 74   "script-fu-sg-t
0b30: 6f 6f 6e 69 6e 61 74 6f 72 22 0a 20 22 3c 49 6d  ooninator". "<Im
0b40: 61 67 65 3e 2f 46 69 6c 74 65 72 73 2f 41 72 74  age>/Filters/Art
0b50: 69 73 74 69 63 2f 22 0a 20 29 0a 0a 0a           istic/". )...