|
3 | 3 | ;
|
4 | 4 | ; Advanced Photo LAB Color Punch script for GIMP 2.4
|
5 | 5 | ; Copyright (C) 2005 Lasm <[email protected]>
|
6 |
| -; http://www.godsimmediatecontact.com |
7 |
| -; http://www.godsdirectcontact.org |
8 |
| -; http://www.raindesigninc.com |
| 6 | +; http://www. gods immediatecontact.com |
| 7 | +; http://www. gods directcontact.org |
| 8 | +; http://www. rain designinc.com |
9 | 9 | ;
|
10 | 10 | ; Tags: color
|
11 | 11 | ;
|
12 | 12 | ; Latest scripts/packages available at
|
13 |
| -; http://sourceforge.net/projects/lasmz/ |
14 |
| -; http://groups.yahoo.com/group/script-fu/ |
| 13 | +; http: // sourceforge.net/projects/lasmz/ |
| 14 | +; http:// groups.yahoo.com/group/script-fu/ |
15 | 15 | ;
|
16 | 16 | ; Welcome to the Line Art Coffee House
|
17 | 17 | ; This Photo LAB Color Punch script is for kung-fu connisseurs only
|
|
153 | 153 | (let* ((curve-value (cons-array 8 'byte)))
|
154 | 154 | (aset curve-value 0 0)
|
155 | 155 | (aset curve-value 1 0)
|
156 |
| - (aset curve-value 2 0) |
| 156 | + (aset curve-value 2 1) ; was 0 |
157 | 157 | (aset curve-value 3 wuji)
|
158 |
| - (aset curve-value 4 255) |
| 158 | + (aset curve-value 4 254) ; was 255 |
159 | 159 | (aset curve-value 5 (- 255 wuji))
|
160 | 160 | (aset curve-value 6 255)
|
161 | 161 | (aset curve-value 7 255)
|
|
165 | 165 |
|
166 | 166 | (define (get-lab-curves saturate? curvestr)
|
167 | 167 | (if (eqv? saturate? TRUE)
|
168 |
| - (curve0 curvestr) |
169 |
| - (curve1 curvestr) |
| 168 | + (begin |
| 169 | + (curve0 curvestr) |
| 170 | + ) |
| 171 | + (begin |
| 172 | + (curve1 curvestr) |
| 173 | + ) |
170 | 174 | )
|
171 | 175 | )
|
172 | 176 |
|
|
198 | 202 | (if (< Bc 2) ;; sat/desat
|
199 | 203 | (append '(1) ((L-list Lc)))
|
200 | 204 | (if (= Bc 2) ;; color-tint
|
201 |
| - (append '(2) ((L-list Lc))) |
202 |
| - (append '(0) ((L-list Lc)))) |
| 205 | + (append '(2) ((L-list Lc))) |
| 206 | + (append '(0) ((L-list Lc))) |
203 | 207 | )
|
| 208 | + ) |
204 | 209 | )
|
205 | 210 | )
|
206 | 211 | (define (B-locked Ac Lc)
|
|
209 | 214 | (append '(1) ((L-list Lc)))
|
210 | 215 | (if (= Ac 2) ;; color-tint
|
211 | 216 | (append '(2) ((L-list Lc)))
|
212 |
| - (append '(0) ((L-list Lc)))) |
| 217 | + (append '(0) ((L-list Lc))) |
213 | 218 | )
|
| 219 | + ) |
214 | 220 | )
|
215 | 221 | )
|
216 | 222 | (define (A-list Ac lB? Bc Lc)
|
|
221 | 227 | (append '(1) ((B-locked Ac Lc)))
|
222 | 228 | (if (= Ac 2) ;; color-tint
|
223 | 229 | (append '(2) ((B-locked Ac Lc)))
|
224 |
| - (append '(0) ((B-locked Ac Lc))))) |
| 230 | + (append '(0) ((B-locked Ac Lc))) |
| 231 | + ) |
225 | 232 | )
|
| 233 | + ) |
226 | 234 | (begin ;; B is un-locked
|
227 | 235 | (if (< Ac 2) ;; sat and desat
|
228 | 236 | (append '(1) ((B-list Bc Lc)))
|
229 | 237 | (if (= Ac 2) ;; color-tint
|
230 |
| - (append '(2) ((B-list Bc Lc))) |
231 |
| - (append '(0) ((B-list Bc Lc))))))) ;;; A-B-L |
| 238 | + (append '(2) ((B-list Bc Lc))) |
| 239 | + (append '(0) ((B-list Bc Lc))) |
| 240 | + ) |
| 241 | + ) |
| 242 | + ) |
| 243 | + ) ;;; A-B-L |
232 | 244 | )
|
233 | 245 | )
|
234 | 246 | (define (read-list ls) ;; cumulative sum of list
|
235 | 247 | (if (null? ls)
|
236 | 248 | 0
|
237 | 249 | (+ (car ls)
|
238 |
| - (read-list (cdr ls)))) |
| 250 | + (read-list (cdr ls))) |
| 251 | + ) |
239 | 252 | )
|
240 | 253 | ; ((A-list Achl lckB? Bchl Lchl))
|
241 | 254 | (if (> Hchl 0)
|
|
250 | 263 | ;
|
251 | 264 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
252 | 265 | (define (calc-color-tint curvestr)
|
253 |
| - (let* ((color-tint (* 2 curvestr))) |
254 |
| - color-tint |
| 266 | + (let* ( |
| 267 | + (color-tint (* 2 curvestr)) |
| 268 | + ) |
| 269 | + color-tint |
255 | 270 | )
|
256 | 271 | )
|
257 | 272 |
|
|
338 | 353 | ; (number->string stat-L)))
|
339 | 354 |
|
340 | 355 | (if (= stat-H 1) ;; start of H channel create mask magic
|
341 |
| - (begin |
| 356 | + (begin |
342 | 357 | (set! hisdw-img (car (gimp-image-new width height 0)))
|
343 | 358 | (set! hisdw-color-layer (car (gimp-layer-new-from-drawable inLayer hisdw-img)))
|
344 | 359 | (gimp-image-insert-layer hisdw-img hisdw-color-layer 0 -1)
|
|
367 | 382 | (gimp-layer-set-apply-mask hisdw-A-layer hisdw-maskA)
|
368 | 383 | )
|
369 | 384 | )
|
370 |
| - (if (= stat-B 1) ;; create B mask and apply it |
371 |
| - (begin |
372 |
| - (gimp-image-set-active-layer gray-img B-layer) |
373 |
| - (set! hisdw-B-layer (copylayer B-layer "B copy")) |
374 |
| - (gimp-image-insert-layer gray-img hisdw-B-layer 0 -1) |
375 |
| - (set! hisdw-B-mask (car (gimp-layer-create-mask hisdw-B-layer 0))) |
376 |
| - (gimp-layer-add-mask hisdw-B-layer hisdw-B-mask) |
377 |
| - (set! hisdw-maskB (car (gimp-edit-paste hisdw-B-mask TRUE))) |
378 |
| - (gimp-floating-sel-anchor hisdw-maskB) |
379 |
| - (gimp-layer-set-apply-mask hisdw-B-layer hisdw-maskB) |
| 385 | + (if (= stat-B 1) ;; create B mask and apply it |
| 386 | + (begin |
| 387 | + (gimp-image-set-active-layer gray-img B-layer) |
| 388 | + (set! hisdw-B-layer (copylayer B-layer "B copy")) |
| 389 | + (gimp-image-insert-layer gray-img hisdw-B-layer 0 -1) |
| 390 | + (set! hisdw-B-mask (car (gimp-layer-create-mask hisdw-B-layer 0))) |
| 391 | + (gimp-layer-add-mask hisdw-B-layer hisdw-B-mask) |
| 392 | + (set! hisdw-maskB (car (gimp-edit-paste hisdw-B-mask TRUE))) |
| 393 | + (gimp-floating-sel-anchor hisdw-maskB) |
| 394 | + (gimp-layer-set-apply-mask hisdw-B-layer hisdw-maskB) |
| 395 | + ) |
380 | 396 | )
|
381 |
| - ) |
382 |
| - (if (= stat-L 1) ;; create L mask and apply it |
383 |
| - (begin |
384 |
| - (gimp-image-set-active-layer gray-img L-layer) |
385 |
| - (set! hisdw-L-layer (copylayer L-layer "L copy")) |
386 |
| - (gimp-image-insert-layer gray-img hisdw-L-layer 0 -1) |
387 |
| - (set! hisdw-L-mask (car (gimp-layer-create-mask hisdw-L-layer 0))) |
388 |
| - (gimp-layer-add-mask hisdw-L-layer hisdw-L-mask) |
389 |
| - (set! hisdw-maskL (car (gimp-edit-paste hisdw-L-mask TRUE))) |
390 |
| - (gimp-floating-sel-anchor hisdw-maskL) |
391 |
| - (gimp-layer-set-apply-mask hisdw-L-layer hisdw-maskL) |
| 397 | + (if (= stat-L 1) ;; create L mask and apply it |
| 398 | + (begin |
| 399 | + (gimp-image-set-active-layer gray-img L-layer) |
| 400 | + (set! hisdw-L-layer (copylayer L-layer "L copy")) |
| 401 | + (gimp-image-insert-layer gray-img hisdw-L-layer 0 -1) |
| 402 | + (set! hisdw-L-mask (car (gimp-layer-create-mask hisdw-L-layer 0))) |
| 403 | + (gimp-layer-add-mask hisdw-L-layer hisdw-L-mask) |
| 404 | + (set! hisdw-maskL (car (gimp-edit-paste hisdw-L-mask TRUE))) |
| 405 | + (gimp-floating-sel-anchor hisdw-maskL) |
| 406 | + (gimp-layer-set-apply-mask hisdw-L-layer hisdw-maskL) |
| 407 | + ) |
392 | 408 | )
|
393 |
| - ) |
394 |
| - ) |
395 |
| - ) ;; end of H channel create mask magic |
| 409 | + ) |
| 410 | + ) ;; end of H channel create mask magic |
396 | 411 |
|
397 | 412 | (if (= Achannel 0)
|
398 | 413 | (begin
|
|
472 | 487 | )
|
473 | 488 | ) ;; end of A tint
|
474 | 489 |
|
475 |
| - |
| 490 | + |
476 | 491 | (if (eqv? lockB? FALSE)
|
477 | 492 | (begin
|
478 | 493 | (if (= Bchannel 0)
|
479 |
| - (gimp-curves-spline B-layer 0 8 (get-lab-curves TRUE curvestr2)) |
480 |
| - (if (= Bchannel 1) |
481 |
| - (gimp-curves-spline B-layer 0 8 (get-lab-curves FALSE curvestr2)) |
| 494 | + (begin |
| 495 | + (gimp-curves-spline B-layer 0 8 (get-lab-curves TRUE curvestr2)) |
| 496 | + ) |
| 497 | + (begin |
| 498 | + (if (= Bchannel 1) |
| 499 | + (gimp-curves-spline B-layer 0 8 (get-lab-curves FALSE curvestr2)) |
| 500 | + ) |
482 | 501 | )
|
483 | 502 | )
|
484 | 503 |
|
|
565 | 584 | )
|
566 | 585 | )
|
567 | 586 | )
|
568 |
| - |
| 587 | + |
569 | 588 | (set! comp-img (car
|
570 | 589 | (plug-in-drawable-compose RUN-NONINTERACTIVE gray-img L-layer A-layer B-layer 0 "Lab")))
|
571 | 590 | (set! tt-d (car (gimp-display-new comp-img))) ;; working
|
|
596 | 615 |
|
597 | 616 | (gimp-context-set-background old-bg)
|
598 | 617 | (gimp-context-set-foreground old-fg)
|
| 618 | + (gc); garbage collect; memory cleanup; arrays were used |
599 | 619 |
|
600 | 620 | )
|
601 | 621 |
|
|
605 | 625 | (script-fu-register
|
606 | 626 | "script-fu-lab-color-punch"
|
607 | 627 | "<Toolbox>/Script-Fu/Colors/Lasm/Lasm LAB Color Punch"
|
608 |
| - "Lasm's famous special effect for photographs. This works on any RGB image. LAB Color Punch gives you the power and freedom to change the color you want ! Caution: it runs slowly on large images. \n file:lasm-lab-color-punch.scm" |
| 628 | + "Lasm's famous special effect for photographs. This works on any RGB image. Allows for power saturation or color-tint. Color tint uses the Strength to determine shade between the 2 colors. Caution: it runs slowly on large images. \n file:lasm-lab-color-punch.scm" |
609 | 629 | "lasm"
|
610 | 630 | "Copyright 2005, lasm"
|
611 | 631 | "Nov 1, 2005"
|
|
615 | 635 | SF-OPTION "Highlight/Shadow" SCRIPT-FU-LAB-COLOR-PUNCH-CHOICE3
|
616 | 636 | SF-ADJUSTMENT "Sensitivity" '(64 0 127 1 10 0 0)
|
617 | 637 | SF-OPTION "Green/Red" SCRIPT-FU-LAB-COLOR-PUNCH-CHOICE1
|
618 |
| - SF-ADJUSTMENT "Strength" '(64 0 127 1 10 1 0) |
619 |
| - SF-TOGGLE "Lock Blue/Yellow" TRUE |
| 638 | + SF-ADJUSTMENT "Gr-Red Strength (0 to 127)" '(94 0 127 1 10 1 0) |
| 639 | + SF-TOGGLE "Lock Blue/Yellow" FALSE |
620 | 640 | SF-OPTION "Blue/Yellow" SCRIPT-FU-LAB-COLOR-PUNCH-CHOICE1
|
621 |
| - SF-ADJUSTMENT "Strength" '(64 0 127 1 10 1 0) |
| 641 | + SF-ADJUSTMENT "Blu-Yel Strength (0-127)" '(85 0 127 1 10 1 0) |
622 | 642 | SF-OPTION "Luminosity" SCRIPT-FU-LAB-COLOR-PUNCH-CHOICE2
|
623 |
| - SF-ADJUSTMENT "Strength" '(64 0 127 1 10 1 0) |
| 643 | + SF-ADJUSTMENT "Strength (0-127)" '(64 0 127 1 10 1 0) |
624 | 644 | SF-TOGGLE "New Layer" TRUE
|
625 | 645 | )
|
626 | 646 |
|
|
0 commit comments