GIMP Script-fu

Hex Artifact Content
Login

Artifact 44019253cbb72ae74415b72a81700f9bfdd0da7f:


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 3b 20  re details...;; 
01f0: 27 69 73 6f 6c 61 74 65 27 20 64 65 6c 65 74 65  'isolate' delete
0200: 20 65 76 65 72 79 74 68 69 6e 67 20 62 75 74 20   everything but 
0210: 74 68 65 20 73 65 6c 65 63 74 69 6f 6e 20 63 6f  the selection co
0220: 6e 74 65 6e 74 73 0a 0a 28 64 65 66 69 6e 65 20  ntents..(define 
0230: 28 73 63 72 69 70 74 2d 66 75 2d 73 67 2d 69 73  (script-fu-sg-is
0240: 6f 6c 61 74 65 20 69 6d 61 67 65 20 64 72 61 77  olate image draw
0250: 61 62 6c 65 29 0a 20 20 28 67 69 6d 70 2d 69 6d  able).  (gimp-im
0260: 61 67 65 2d 75 6e 64 6f 2d 67 72 6f 75 70 2d 73  age-undo-group-s
0270: 74 61 72 74 20 69 6d 61 67 65 29 0a 20 20 28 67  tart image).  (g
0280: 69 6d 70 2d 63 6f 6e 74 65 78 74 2d 70 75 73 68  imp-context-push
0290: 29 0a 20 20 28 67 69 6d 70 2d 63 6f 6e 74 65 78  ).  (gimp-contex
02a0: 74 2d 73 65 74 2d 64 65 66 61 75 6c 74 2d 63 6f  t-set-default-co
02b0: 6c 6f 72 73 29 0a 20 20 28 6c 65 74 20 28 28 6f  lors).  (let ((o
02c0: 72 69 67 2d 73 65 6c 20 28 63 61 72 20 28 67 69  rig-sel (car (gi
02d0: 6d 70 2d 73 65 6c 65 63 74 69 6f 6e 2d 73 61 76  mp-selection-sav
02e0: 65 20 69 6d 61 67 65 29 29 29 29 0a 20 20 20 20  e image)))).    
02f0: 28 63 6f 6e 64 0a 20 20 20 20 20 20 28 28 3d 20  (cond.      ((= 
0300: 28 63 61 72 20 28 67 69 6d 70 2d 64 72 61 77 61  (car (gimp-drawa
0310: 62 6c 65 2d 69 73 2d 6c 61 79 65 72 20 64 72 61  ble-is-layer dra
0320: 77 61 62 6c 65 29 29 20 54 52 55 45 29 0a 20 20  wable)) TRUE).  
0330: 20 20 20 20 20 20 28 67 69 6d 70 2d 6c 61 79 65        (gimp-laye
0340: 72 2d 61 64 64 2d 61 6c 70 68 61 20 64 72 61 77  r-add-alpha draw
0350: 61 62 6c 65 29 0a 20 20 20 20 20 20 20 20 28 67  able).        (g
0360: 69 6d 70 2d 73 65 6c 65 63 74 69 6f 6e 2d 69 6e  imp-selection-in
0370: 76 65 72 74 20 69 6d 61 67 65 29 0a 20 20 20 20  vert image).    
0380: 20 20 20 20 28 67 69 6d 70 2d 65 64 69 74 2d 63      (gimp-edit-c
0390: 6c 65 61 72 20 64 72 61 77 61 62 6c 65 29 0a 20  lear drawable). 
03a0: 20 20 20 20 20 20 20 28 67 69 6d 70 2d 73 65 6c         (gimp-sel
03b0: 65 63 74 69 6f 6e 2d 6c 6f 61 64 20 6f 72 69 67  ection-load orig
03c0: 2d 73 65 6c 29 20 29 0a 20 20 20 20 20 20 28 28  -sel) ).      ((
03d0: 6f 72 20 28 3d 20 28 63 61 72 20 28 67 69 6d 70  or (= (car (gimp
03e0: 2d 64 72 61 77 61 62 6c 65 2d 69 73 2d 63 68 61  -drawable-is-cha
03f0: 6e 6e 65 6c 20 64 72 61 77 61 62 6c 65 29 29 20  nnel drawable)) 
0400: 54 52 55 45 29 0a 20 20 20 20 20 20 20 20 20 20  TRUE).          
0410: 20 28 3d 20 28 63 61 72 20 28 67 69 6d 70 2d 64   (= (car (gimp-d
0420: 72 61 77 61 62 6c 65 2d 69 73 2d 6c 61 79 65 72  rawable-is-layer
0430: 2d 6d 61 73 6b 20 64 72 61 77 61 62 6c 65 29 29  -mask drawable))
0440: 20 54 52 55 45 29 20 29 0a 20 20 20 20 20 20 20   TRUE) ).       
0450: 20 28 67 69 6d 70 2d 73 65 6c 65 63 74 69 6f 6e   (gimp-selection
0460: 2d 6e 6f 6e 65 20 69 6d 61 67 65 29 0a 20 20 20  -none image).   
0470: 20 20 20 20 20 28 67 69 6d 70 2d 65 64 69 74 2d       (gimp-edit-
0480: 66 69 6c 6c 20 64 72 61 77 61 62 6c 65 20 46 4f  fill drawable FO
0490: 52 45 47 52 4f 55 4e 44 2d 46 49 4c 4c 29 0a 20  REGROUND-FILL). 
04a0: 20 20 20 20 20 20 20 28 67 69 6d 70 2d 73 65 6c         (gimp-sel
04b0: 65 63 74 69 6f 6e 2d 6c 6f 61 64 20 6f 72 69 67  ection-load orig
04c0: 2d 73 65 6c 29 0a 20 20 20 20 20 20 20 20 28 67  -sel).        (g
04d0: 69 6d 70 2d 65 64 69 74 2d 66 69 6c 6c 20 64 72  imp-edit-fill dr
04e0: 61 77 61 62 6c 65 20 42 41 43 4b 47 52 4f 55 4e  awable BACKGROUN
04f0: 44 2d 46 49 4c 4c 29 20 29 29 0a 20 20 20 20 28  D-FILL) )).    (
0500: 67 69 6d 70 2d 69 6d 61 67 65 2d 72 65 6d 6f 76  gimp-image-remov
0510: 65 2d 63 68 61 6e 6e 65 6c 20 69 6d 61 67 65 20  e-channel image 
0520: 6f 72 69 67 2d 73 65 6c 29 20 29 0a 20 20 28 67  orig-sel) ).  (g
0530: 69 6d 70 2d 63 6f 6e 74 65 78 74 2d 70 6f 70 29  imp-context-pop)
0540: 20 20 20 20 20 20 20 20 0a 20 20 28 67 69 6d 70          .  (gimp
0550: 2d 69 6d 61 67 65 2d 75 6e 64 6f 2d 67 72 6f 75  -image-undo-grou
0560: 70 2d 65 6e 64 20 69 6d 61 67 65 29 0a 20 20 28  p-end image).  (
0570: 67 69 6d 70 2d 64 69 73 70 6c 61 79 73 2d 66 6c  gimp-displays-fl
0580: 75 73 68 29 0a 20 20 29 0a 0a 28 73 63 72 69 70  ush).  )..(scrip
0590: 74 2d 66 75 2d 72 65 67 69 73 74 65 72 20 22 73  t-fu-register "s
05a0: 63 72 69 70 74 2d 66 75 2d 73 67 2d 69 73 6f 6c  cript-fu-sg-isol
05b0: 61 74 65 22 0a 20 20 22 49 73 6f 6c 61 74 65 22  ate".  "Isolate"
05c0: 0a 20 20 22 52 65 6d 6f 76 65 20 61 6c 6c 20 63  .  "Remove all c
05d0: 6f 6e 74 65 6e 74 20 65 78 63 65 70 74 20 74 68  ontent except th
05e0: 65 20 73 65 6c 65 63 74 69 6f 6e 22 0a 20 20 22  e selection".  "
05f0: 53 61 75 6c 20 47 6f 6f 64 65 22 0a 20 20 22 73  Saul Goode".  "s
0600: 61 75 6c 67 6f 6f 64 65 22 0a 20 20 22 35 2f 32  aulgoode".  "5/2
0610: 31 2f 32 30 30 37 22 0a 20 20 22 2a 22 0a 20 20  1/2007".  "*".  
0620: 53 46 2d 49 4d 41 47 45 20 20 20 20 22 49 6d 61  SF-IMAGE    "Ima
0630: 67 65 22 20 20 20 20 30 0a 20 20 53 46 2d 44 52  ge"    0.  SF-DR
0640: 41 57 41 42 4c 45 20 22 44 72 61 77 61 62 6c 65  AWABLE "Drawable
0650: 22 20 30 0a 20 20 29 0a 28 73 63 72 69 70 74 2d  " 0.  ).(script-
0660: 66 75 2d 6d 65 6e 75 2d 72 65 67 69 73 74 65 72  fu-menu-register
0670: 20 22 73 63 72 69 70 74 2d 66 75 2d 73 67 2d 69   "script-fu-sg-i
0680: 73 6f 6c 61 74 65 22 0a 20 20 22 3c 49 6d 61 67  solate".  "<Imag
0690: 65 3e 2f 45 64 69 74 2f 43 6c 65 61 72 22 0a 20  e>/Edit/Clear". 
06a0: 20 29 0a                                          ).