From 00abb6f86489dbac1686f47759429a7e4f0ddd08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20R=2E=20Pietraszczyk?= Date: Mon, 10 Feb 2025 17:30:08 +0100 Subject: Init again --- 3.0/przem-add-background-under-text-v3.scm | 86 ++++++++++++++++++++++++ 3.0/przem-apply-sepia-v3.scm | 104 +++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 3.0/przem-add-background-under-text-v3.scm create mode 100644 3.0/przem-apply-sepia-v3.scm (limited to '3.0') diff --git a/3.0/przem-add-background-under-text-v3.scm b/3.0/przem-add-background-under-text-v3.scm new file mode 100644 index 0000000..212a665 --- /dev/null +++ b/3.0/przem-add-background-under-text-v3.scm @@ -0,0 +1,86 @@ +; przem-add-background-under-text-v3 - Script-fu dodający podpis z tłem +; author: PRP +; licencja: Public Domain +; Gdańsk - 06-02-2025 +; ver. 1.250210-0~alpha for Gimp 3.0 + +(define (przem-add-background-under-text-v3 image drawable text font font-size color background-transparency opacity) + + (gimp-image-undo-group-start image) + + (let* ( + (image-width (car (gimp-image-get-width image))) + (image-height (car (gimp-image-get-height image))) + ;(text-extents (gimp-text-get-extents-fontname text font-size 0 font)) + (text-extents (gimp-text-get-extents-font text font-size font)) + (text-width (car text-extents)) + (text-height (cadr text-extents)) + (pos-x (- (- image-width text-width) 40)) + (pos-y (- image-height text-height)) + (bg-x-left (- pos-x 10)) + (bg-x-right (+ text-width 10)) + ;(text-layer (car (gimp-text-fontname image -1 0 0 text 0 TRUE font-size 0 font))) + (text-layer (car(gimp-text-font image -1 0 0 text 0 TRUE font-size font))) + (bg-layer (car (gimp-layer-new image bg-x-right text-height RGBA-IMAGE "Background" 100 LAYER-MODE-NORMAL))) + (is-nocolorful (car (gimp-drawable-is-gray drawable))) ; czy obraz jest w odcieniach szarości + ) + + ; Ustawienie koloru tła + (gimp-context-set-background color) + (gimp-drawable-fill bg-layer FILL-BACKGROUND) + (gimp-layer-set-opacity bg-layer opacity) + + ; jeśli obraz jest szary to konwertuje go na RGB - tak na sztukę + (if (= is-nocolorful TRUE) + (gimp-image-convert-rgb image) + ) + + ; Dodanie warstwy tła pod tekstem + (gimp-image-insert-layer image bg-layer 0 -1) + + ;(gimp-layer-translate bg-layer bg-x-left pos-y) + (gimp-selection-translate image bg-layer bg-x-left pos-y) + + (if (= background-transparency TRUE) + (begin + (gimp-drawable-fill bg-layer FILL-TRANSPARENT) + ) + (begin ; else + ) + ) + + ; Ustawienie pozycji tekstu + (gimp-layer-set-offsets text-layer pos-x pos-y) + + ; Przesuń warstwę tekstową na górę stosu warstw + (gimp-image-raise-item-to-top image text-layer) + + ; Scalanie warstw + (gimp-image-merge-down image text-layer CLIP-TO-IMAGE) + + ; Aktualizacja widoku + (gimp-displays-flush) + + (gimp-image-undo-group-end image) ; Zakończ grupę operacji undo + ) +) + +(script-fu-register "przem-add-background-under-text-v3" + _"Add Background Under Text" + _"Dodaje kolorowe tło pod tekstem z możliwością wyboru czcionki i rozmiaru." + "Przemysław R. Pietraszczyk" + "Public Domain" + "2025-02-06" + "RGB* GRAY*" + SF-IMAGE "Image" 0 + SF-DRAWABLE "Drawable" 0 + SF-STRING "Text" "Doda Elektroda" + SF-FONT "Font" "Sans-serif" + SF-ADJUSTMENT "Font Size" '(50 1 1000 1 10 0 1) + SF-COLOR "Background Color" '(255 215 0) + SF-TOGGLE "Background Transparency" FALSE + SF-ADJUSTMENT "Transparency Value" '(100 1 100 1 10 0 1) +) + +(script-fu-menu-register "przem-add-background-under-text-v3" + "/Filters/PIETRASZCZYK/") diff --git a/3.0/przem-apply-sepia-v3.scm b/3.0/przem-apply-sepia-v3.scm new file mode 100644 index 0000000..494bae9 --- /dev/null +++ b/3.0/przem-apply-sepia-v3.scm @@ -0,0 +1,104 @@ +; przem-apply-sepia-v3 - Script-fu dodający prawdziwą sepie do zdjęcia +; author: PRP +; licencja: Public Domain +; Gdańsk - 07-02-2025 +; ver. 1.2502010-4 for GIMP 3 + +(define (przem-apply-sepia-v3 image drawable value-slider-sepia gradient-reverse gradient-shape) + + (let* ( + (image-width (car (gimp-image-get-width image))) + (image-height (car (gimp-image-get-height image))) + (center-x (/ image-width 2)) + (center-y (* image-height 0.5)) ; either is OK + (sepia-layer (car (gimp-layer-new image image-width image-height RGBA-IMAGE "Sepia Layer" 100 LAYER-MODE-NORMAL))) + (is-nocolorful (car (gimp-drawable-is-gray drawable))) ; czy obraz jest w odcieniach szarości + ) + + (gimp-image-undo-group-start image) + ;(gimp-image-undo-disable image) + + + + ; jeśli obraz jest szary to konwertuje go na RGB - tak na sztukę + (if (= is-nocolorful TRUE) + (gimp-image-convert-rgb image) + ) + + ; Konwersja obrazu do skali szarości + ;(gimp-desaturate drawable) + (gimp-drawable-desaturate drawable DESATURATE-LIGHTNESS) + + ; Dodanie koloru sepii + ;(gimp-context-set-foreground '(112 66 20)) ; Kolor sepii + + (gimp-image-insert-layer image sepia-layer 0 -1) + + + (gimp-context-push) + (gimp-context-set-foreground (list 112 66 20)) ; ciemniejsza + (gimp-context-set-background (list 210 180 140)) ; jasniejsza + ;(plug-in-checkerboard #:run-mode RUN-NONINTERACTIVE + ; #:image image + ; #:drawables (vector drawable) + ; #:psychobilly 0 + ; #:check-size 8) + (plug-in-checkerboard RUN-NONINTERACTIVE image (vector sepia-layer) 0 8) + + (gimp-context-pop) + + (gimp-context-push) + + (gimp-selection-all image) + ; tak było w v. 2.10 + ;(gimp-edit-blend sepia-layer FG-BG-RGB-MODE NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE TRUE 3 0 TRUE 0 0 image-width image-height) + (if (= gradient-shape TRUE) + (begin + (gimp-context-set-gradient-reverse gradient-reverse) + (gimp-drawable-edit-gradient-fill sepia-layer + GRADIENT-LINEAR 0 + FALSE 1 0 + TRUE + 0 0 image-width image-height) + ) + (begin + (gimp-context-set-gradient-reverse gradient-reverse) + (gimp-drawable-edit-gradient-fill sepia-layer + GRADIENT-SHAPEBURST-DIMPLED 0 + FALSE 1 0 + TRUE + 0 0 image-width image-height) + ) ) + + (gimp-context-pop) + + + ; Zmiana krycia warstwy + (gimp-layer-set-opacity sepia-layer value-slider-sepia) + + (gimp-image-merge-down image sepia-layer CLIP-TO-IMAGE) + + (gimp-image-undo-group-end image) + ;(gimp-image-undo-enable image) + + (gimp-displays-flush) +) ) + +(script-fu-register "przem-apply-sepia-v3" + _"Apply a sepia effect to the image" + _"Tworzy obraz sepii" + "Przemyslaw R. Pietraszczyk" + "Public Domain" + "2025-02-07" + "RGB* GRAY*" + SF-IMAGE "Image" 0 + SF-DRAWABLE "Drawable" 0 + SF-ADJUSTMENT "Sepia intensity" '(50 0 100 1 10 0 0) ; Suwak poziomy + SF-TOGGLE "Gradient reverse" FALSE + SF-TOGGLE "Shape" TRUE + + +) + +(script-fu-menu-register "przem-apply-sepia-v3" + "/Filters/PIETRASZCZYK/") -- cgit v1.2.3