Peter424
Nowicjusz
Reputacja: 0
Offline
Wiadomości: 3 Galeria Użytkownika
|
|
« : 18.10.2024, 07:16:54 » |
|
Chciałbym wymienić masowo kolory na zdjęciach (z 1 identycznego koloru na inny kolor) z automatu (nie wiem zdjęć wgranych do 1 folderu).
Doczytałem, że może to zrobić dobrze napisany skrypt, aby nie musieć ręcznie tego robić. Dla mnie jest to magia, więc zlecę napisanie takiego skryptu.
Proszę o kontakt osoby, która może to ogarnąć.
PS
|
|
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #1 : 18.10.2024, 16:59:11 » |
|
Pytanie, co znaczy zmienić kolor. Jak bardzo skomplikowane są to zdjęcia, kwestia odcieni itp, może zapostuj chociaż jedno (możesz fragment, albo podobne stokowe), aby można było ocenić co dokładnie chcesz zmienić.
|
|
|
Zapisane
|
|
|
|
Peter424
Nowicjusz
Reputacja: 0
Offline
Wiadomości: 3 Galeria Użytkownika
|
|
« Odpowiedz #2 : 18.10.2024, 17:06:11 » |
|
Kolor z palety (np. czerwony) na przygotowany deseń. Teraz robię to ręczenie (różdżka), zaznaczam kolor na produkcie, klikam w deseń przygotowany, wypełnił deseniem i wyeksportuje do .jpg. Jeśli jest szansa wykonania takiego skryptu to bardzo proszę o telefon w wolnej chwili (wyjaśnię szczegóły) 603036361
|
|
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #3 : 18.10.2024, 20:34:52 » |
|
No dobra, ale jak ma automat wiedzieć gdzie kliknąć różdżką. Zamieść jakiś przykład.
|
|
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #4 : 19.10.2024, 20:22:54 » |
|
(define (script-fu-replace-with-selection image drawable new-color) (gimp-context-push) (gimp-image-undo-group-start image)
(let* ( (left-top-x 0) (left-top-y 0)
(color-at-point (car (gimp-image-pick-color image drawable left-top-x left-top-y FALSE FALSE 0))) ) (gimp-context-set-foreground color-at-point) (gimp-fuzzy-select drawable left-top-x left-top-y 0 CHANNEL-OP-REPLACE TRUE TRUE 15.0 FALSE) (gimp-selection-invert image) (gimp-context-set-foreground new-color) (gimp-edit-fill drawable FOREGROUND-FILL) )
(gimp-image-undo-group-end image)
(gimp-displays-flush) (gimp-context-pop) )
(script-fu-register "script-fu-replace-with-selection" ; Nazwa skryptu "Replace with Selection" ; Nazwa w interfejsie "Pick color from top-left, invert selection and fill" ; Opis "Your Name" ; Autor "Your License" ; Licencja "2024" ; Rok "*" ; Typ obrazu (dla wszystkich) SF-IMAGE "Image" 0 ; Parametry: Obraz SF-DRAWABLE "Drawable" 0 ; Parametry: Warstwa SF-COLOR "New Color" '(0 0 0) ; Nowy kolor (czarny domyślnie) )
(script-fu-menu-register "script-fu-replace-with-selection" "<Image>/Filters/Custom")
Spróbuj czy to robi, co chcesz.
|
|
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #5 : 20.10.2024, 19:50:48 » |
|
Wywoływanie tego tego skryptu z konsoli: (define (script-fu-replace-with-selection image drawable new-color) (gimp-context-push) (gimp-image-undo-group-start image)
(let* ( (left-top-x 0) (left-top-y 0)
(color-at-point (car (gimp-image-pick-color image drawable left-top-x left-top-y FALSE FALSE 0))) ) (gimp-context-set-foreground color-at-point) (gimp-fuzzy-select drawable left-top-x left-top-y 0 CHANNEL-OP-REPLACE TRUE TRUE 15.0 FALSE) (gimp-selection-invert image) (gimp-context-set-foreground new-color) (gimp-edit-fill drawable FOREGROUND-FILL) )
(gimp-image-undo-group-end image)
(gimp-displays-flush) (gimp-context-pop) )
(define (filename-from-path path) (car (reverse (strbreakup path "\\"))) )
(define (basename-from-filename file-name) (car (strbreakup file-name ".")) )
(define (script-fu-replace-with-selection-batch new-color input-pattern result-directory) (let* ( (files (cadr (file-glob input-pattern 1))) ) (while (not (null? files)) (let* ( (file-name (car files)) (output-filename (string-append result-directory "\\" (basename-from-filename (filename-from-path file-name)) ".jpg")) (image (car (gimp-file-load RUN-NONINTERACTIVE file-name file-name))) (drawable (car (gimp-image-get-active-layer image))) ) (script-fu-replace-with-selection image drawable new-color) (gimp-file-save RUN-NONINTERACTIVE image drawable output-filename output-filename) (gimp-image-delete image) ) (set! files (cdr files)) ) )) Uruchamia się to poleceniem: "C:\Program Files\GIMP 2\bin\gimp-2.10.exe" -i -b "(script-fu-replace-with-selection-batch '(255 0 0) \"input\\*.jpg\" \"output\")" -b "(gimp-quit 0)" To, zostało wywołane w katalogu, gdzie znajduje się katalog "input" (w nim są pliki JPG, którym kolor zmieniamy), w "output" zapisują się wyniki.
|
|
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #6 : 22.10.2024, 21:40:24 » |
|
Podmieniłem nieco ustawienia wywołania też różdżki na zbliżone do domyślnych. W sumie zmieniła się tylko jedna linijka (ta z gimp-fuzzy-select). (define (script-fu-replace-with-selection image drawable new-color) (gimp-context-push) (gimp-image-undo-group-start image)
(let* ( (left-top-x 0) (left-top-y 0)
(color-at-point (car (gimp-image-pick-color image drawable left-top-x left-top-y FALSE FALSE 0))) ) (gimp-context-set-foreground color-at-point) (gimp-fuzzy-select drawable left-top-x left-top-y 15 CHANNEL-OP-REPLACE TRUE TRUE 5.0 FALSE) (gimp-selection-invert image) (gimp-context-set-foreground new-color) (gimp-edit-fill drawable FOREGROUND-FILL) )
(gimp-image-undo-group-end image)
(gimp-displays-flush) (gimp-context-pop) )
(define (filename-from-path path) (car (reverse (strbreakup path "\\"))) )
(define (basename-from-filename file-name) (car (strbreakup file-name ".")) )
(define (script-fu-replace-with-selection-batch new-color input-pattern result-directory) (let* ( (files (cadr (file-glob input-pattern 1))) ) (while (not (null? files)) (let* ( (file-name (car files)) (output-filename (string-append result-directory "\\" (basename-from-filename (filename-from-path file-name)) ".jpg")) (image (car (gimp-file-load RUN-NONINTERACTIVE file-name file-name))) (drawable (car (gimp-image-get-active-layer image))) ) (script-fu-replace-with-selection image drawable new-color) (gimp-file-save RUN-NONINTERACTIVE image drawable output-filename output-filename) (gimp-image-delete image) ) (set! files (cdr files)) ) ))
|
|
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #7 : 24.10.2024, 20:31:04 » |
|
Zmiana podejścia, tym razem korzystam z funkcji gimp-image-select-color (define (script-fu-replace-with-selection image drawable new-color threshold) (gimp-context-push) (gimp-image-undo-group-start image)
(let* ( (left-top-x 0) (left-top-y 0)
(color-at-point (car (gimp-image-pick-color image drawable left-top-x left-top-y FALSE FALSE 0))) ) (gimp-context-set-foreground color-at-point) (gimp-context-set-sample-threshold threshold) (gimp-image-select-color image CHANNEL-OP-ADD drawable '(0 0 0)) (gimp-context-set-foreground new-color) (gimp-edit-fill drawable FOREGROUND-FILL) )
(gimp-image-undo-group-end image)
(gimp-displays-flush) (gimp-context-pop) )
(script-fu-register "script-fu-replace-with-selection" ; Nazwa skryptu "Replace with Selection" ; Nazwa w interfejsie "Pick color from top-left, invert selection and fill" ; Opis "Your Name" ; Autor "Your License" ; Licencja "2024" ; Rok "*" ; Typ obrazu (dla wszystkich) SF-IMAGE "Image" 0 ; Parametry: Obraz SF-DRAWABLE "Drawable" 0 ; Parametry: Warstwa SF-COLOR "New Color" '(0 0 0) ; Nowy kolor (czarny domyślnie) SF-ADJUSTMENT "Threshold" '(0.15 0.0 1.0 0.01 0.1 2 0) ; Próg wyboru koloru )
(script-fu-menu-register "script-fu-replace-with-selection" "<Image>/Filters/Custom")
|
|
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #8 : 26.10.2024, 14:20:09 » |
|
Bez zmiękczania krawędzi. (define (script-fu-replace-with-selection image drawable new-color threshold) (gimp-context-push) (gimp-image-undo-group-start image)
(let* ( (left-top-x 0) (left-top-y 0)
(color-at-point (car (gimp-image-pick-color image drawable left-top-x left-top-y FALSE FALSE 0))) ) (gimp-context-set-foreground color-at-point) (gimp-context-set-antialias TRUE) (gimp-context-set-feather FALSE) (gimp-context-set-sample-threshold threshold) (gimp-image-select-color image CHANNEL-OP-ADD drawable '(0 0 0)) (gimp-context-set-foreground new-color) (gimp-edit-fill drawable FOREGROUND-FILL) )
(gimp-image-undo-group-end image)
(gimp-displays-flush) (gimp-context-pop) )
(script-fu-register "script-fu-replace-with-selection" ; Nazwa skryptu "Replace with Selection" ; Nazwa w interfejsie "Pick color from top-left, invert selection and fill" ; Opis "Your Name" ; Autor "Your License" ; Licencja "2024" ; Rok "*" ; Typ obrazu (dla wszystkich) SF-IMAGE "Image" 0 ; Parametry: Obraz SF-DRAWABLE "Drawable" 0 ; Parametry: Warstwa SF-COLOR "New Color" '(0 0 0) ; Nowy kolor (czarny domyślnie) SF-ADJUSTMENT "Threshold" '(0.15 0.0 1.0 0.01 0.1 2 0) ; Próg wyboru koloru )
(script-fu-menu-register "script-fu-replace-with-selection" "<Image>/Filters/Custom")
|
|
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #9 : 26.10.2024, 20:57:45 » |
|
Wyłączony antyaliasing też (define (script-fu-replace-with-selection image drawable new-color threshold) (gimp-context-push) (gimp-image-undo-group-start image)
(let* ( (left-top-x 0) (left-top-y 0)
(color-at-point (car (gimp-image-pick-color image drawable left-top-x left-top-y FALSE FALSE 0))) ) (gimp-context-set-foreground color-at-point) (gimp-context-set-antialias FALSE) (gimp-context-set-feather FALSE) (gimp-context-set-sample-threshold threshold) (gimp-image-select-color image CHANNEL-OP-ADD drawable '(0 0 0)) (gimp-context-set-foreground new-color) (gimp-edit-fill drawable FOREGROUND-FILL) (gimp-selection-none image) )
(gimp-image-undo-group-end image)
(gimp-displays-flush) (gimp-context-pop) )
(script-fu-register "script-fu-replace-with-selection" ; Nazwa skryptu "Replace with Selection" ; Nazwa w interfejsie "Pick color from top-left, invert selection and fill" ; Opis "Your Name" ; Autor "Your License" ; Licencja "2024" ; Rok "*" ; Typ obrazu (dla wszystkich) SF-IMAGE "Image" 0 ; Parametry: Obraz SF-DRAWABLE "Drawable" 0 ; Parametry: Warstwa SF-COLOR "New Color" '(0 0 0) ; Nowy kolor (czarny domyślnie) SF-ADJUSTMENT "Threshold" '(0.15 0.0 1.0 0.01 0.1 2 0) ; Próg wyboru koloru )
(script-fu-menu-register "script-fu-replace-with-selection" "<Image>/Filters/Custom")
|
|
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #10 : 27.10.2024, 21:58:44 » |
|
Wypełnienie koloru czarnego zadanym deseniem ("2a" tutaj): (define (script-fu-fill-black-with-pattern image drawable) (gimp-context-push) (gimp-image-undo-group-start image)
(let* ( (left-top-x 0) (left-top-y 0)
(color-at-point (car (gimp-image-pick-color image drawable left-top-x left-top-y FALSE FALSE 0))) ) (gimp-context-set-foreground color-at-point) (gimp-context-set-antialias FALSE) (gimp-context-set-feather FALSE) (gimp-context-set-sample-threshold 0.3) (gimp-image-select-color image CHANNEL-OP-ADD drawable '(0 0 0))
(gimp-context-set-pattern "2a") (gimp-edit-bucket-fill drawable BUCKET-FILL-PATTERN NORMAL-MODE 100 0 FALSE 0 0)
(gimp-selection-none image) )
(gimp-image-undo-group-end image)
(gimp-displays-flush) (gimp-context-pop) )
(script-fu-register "script-fu-fill-black-with-pattern" ;; Script name "Fill Black Areas with Pattern" ;; Menu label "Fills all black areas with a specified pattern" ;; Description "Your Name" ;; Author "Your License" ;; License "2024" ;; Year "*" ;; Image types SF-IMAGE "Image" 0 ;; Input image SF-DRAWABLE "Drawable" 0 ;; Input layer )
(script-fu-menu-register "script-fu-fill-black-with-pattern" "<Image>/Filters/Custom")
|
|
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #11 : 28.10.2024, 18:32:32 » |
|
Wersja pod uruchamianie masowe: (define (script-fu-fill-black-with-pattern image drawable) (gimp-context-push)
(gimp-image-undo-group-start image)
(gimp-context-set-antialias FALSE) (gimp-context-set-feather FALSE) (gimp-context-set-sample-threshold 0.3) (gimp-image-select-color image CHANNEL-OP-ADD drawable '(0 0 0))
(gimp-context-set-pattern "2a") (gimp-edit-bucket-fill drawable BUCKET-FILL-PATTERN NORMAL-MODE 100 0 FALSE 0 0)
(gimp-selection-none image)
(gimp-displays-flush) (gimp-image-undo-group-end image)
(gimp-context-pop) )
(define (filename-from-path path) (car (reverse (strbreakup path "\\"))) )
(define (basename-from-filename file-name) (car (strbreakup file-name ".")) )
(define (script-fu-fill-black-with-pattern-batch input-pattern result-directory) (let* ( (files (cadr (file-glob input-pattern 1))) ) (while (not (null? files)) (let* ( (file-name (car files)) (output-filename (string-append result-directory "\\" (basename-from-filename (filename-from-path file-name)) ".jpg")) (image (car (gimp-file-load RUN-NONINTERACTIVE file-name file-name))) (drawable (car (gimp-image-get-active-layer image))) ) (script-fu-fill-black-with-pattern image drawable) (gimp-file-save RUN-NONINTERACTIVE image drawable output-filename output-filename) (gimp-image-delete image) ) (set! files (cdr files)) ) ))
Wywołanie na Windowsie: "C:\Program Files\GIMP 2\bin\gimp-2.10.exe" -i -b "(script-fu-fill-black-with-pattern-batch \"input\\*.jpg\" \"output\")" -b "(gimp-quit 0)"
|
|
« Ostatnia zmiana: 28.10.2024, 22:09:04 wysłane przez Ziomioslaw »
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #12 : 01.11.2024, 16:54:34 » |
|
Podmieniony sposób lokalizacji obiektu: (define (script-fu-fill-black-with-pattern image drawable) (gimp-context-push)
(gimp-image-undo-group-start image)
(gimp-fuzzy-select drawable 0 0 15 CHANNEL-OP-REPLACE TRUE TRUE 3.0 FALSE) (gimp-selection-invert image)
(gimp-context-set-pattern "2a") (gimp-edit-bucket-fill drawable BUCKET-FILL-PATTERN NORMAL-MODE 100 0 FALSE 0 0)
(gimp-selection-none image)
(gimp-displays-flush) (gimp-image-undo-group-end image)
(gimp-context-pop) )
(define (filename-from-path path) (car (reverse (strbreakup path "\\"))) )
(define (basename-from-filename file-name) (car (strbreakup file-name ".")) )
(define (script-fu-fill-black-with-pattern-batch input-pattern result-directory) (let* ( (files (cadr (file-glob input-pattern 1))) ) (while (not (null? files)) (let* ( (file-name (car files)) (output-filename (string-append result-directory "\\" (basename-from-filename (filename-from-path file-name)) ".jpg")) (image (car (gimp-file-load RUN-NONINTERACTIVE file-name file-name))) (drawable (car (gimp-image-get-active-layer image))) ) (script-fu-fill-black-with-pattern image drawable) (gimp-file-save RUN-NONINTERACTIVE image drawable output-filename output-filename) (gimp-image-delete image) ) (set! files (cdr files)) ) )) Komenda do wywoływania: "C:\Program Files\GIMP 2\bin\gimp-2.10.exe" -i -b "(script-fu-fill-black-with-pattern-batch \"input\\*.jpg\" \"output\")" -b "(gimp-quit 0)"
|
|
|
Zapisane
|
|
|
|
Ziomioslaw
Administrator
Reputacja: 46
Offline
Płeć:
GIMP: 2.10
JID: ziomioslaw@jabber.org
Licencja: Copyright
Wiadomości: 7 451 Galeria Użytkownika
Cyklista Apokalipsy
|
|
« Odpowiedz #13 : 02.11.2024, 15:49:18 » |
|
To samo co poprzednio, ale podmieniona funkcja wyciągająca nazwę pliku (nietestowana przeze mnie całkowicie, ale podobno działa): (define (script-fu-fill-black-with-pattern image drawable) (gimp-context-push)
(gimp-image-undo-group-start image)
(gimp-fuzzy-select drawable 0 0 15 CHANNEL-OP-REPLACE TRUE TRUE 3.0 FALSE) (gimp-selection-invert image)
(gimp-context-set-pattern "2a") (gimp-edit-bucket-fill drawable BUCKET-FILL-PATTERN NORMAL-MODE 100 0 FALSE 0 0)
(gimp-selection-none image)
(gimp-displays-flush) (gimp-image-undo-group-end image)
(gimp-context-pop) )
(define (filename-from-path path) (car (reverse (strbreakup path "\\"))) )
(define (basename-from-filename file-name) (let* ( (tokens (reverse (strbreakup file-name "."))) ) (if (> (length tokens) 1) (unbreakupstr (reverse (cdr tokens)) ".") file-name ) ))
(define (script-fu-fill-black-with-pattern-batch input-pattern result-directory) (let* ( (files (cadr (file-glob input-pattern 1))) ) (while (not (null? files)) (let* ( (file-name (car files)) (output-filename (string-append result-directory "\\" (basename-from-filename (filename-from-path file-name)) ".jpg")) (image (car (gimp-file-load RUN-NONINTERACTIVE file-name file-name))) (drawable (car (gimp-image-get-active-layer image))) ) (script-fu-fill-black-with-pattern image drawable) (gimp-file-save RUN-NONINTERACTIVE image drawable output-filename output-filename) (gimp-image-delete image) ) (set! files (cdr files)) ) )) Wywołanie: "C:\Program Files\GIMP 2\bin\gimp-2.10.exe" -i -b "(script-fu-fill-black-with-pattern-batch \"input\\*.jpg\" \"output\")" -b "(gimp-quit 0)"
|
|
« Ostatnia zmiana: 03.11.2024, 20:54:50 wysłane przez Ziomioslaw »
|
Zapisane
|
|
|
|