Nie będzie widoczny w GIMP-ie, bo brakuje rejestracji, on został przeznaczony do uruchamiania we wierszu poleceń
"2x ma być batch?", tak to poprawne, bo koślawo napisałem tę nazwę, ona jest tutaj:
Kod:
(define (batch-center-on-background-batch background-file (...)
Poprawiłem ten skrypt i nazwy do niego, plus kierunek slashy, bo Windows to dalej ma je źle:
Kod:
(define (center-on-background background-file input-file output-file)
(let* (
(input-image (car (gimp-file-load RUN-NONINTERACTIVE input-file input-file)))
(background-image (car (gimp-file-load RUN-NONINTERACTIVE background-file background-file)))
(input-layer (car (gimp-image-get-active-layer input-image)))
(bg-width (car (gimp-image-width background-image)))
(bg-height (car (gimp-image-height background-image)))
(input-width (car (gimp-image-width input-image)))
(input-height (car (gimp-image-height input-image)))
(x-pos (/ (- bg-width input-width) 2))
(y-pos (/ (- bg-height input-height) 2))
)
(gimp-edit-copy input-layer)
(let* (
(new-layer (car (gimp-layer-new background-image bg-width bg-height RGBA-IMAGE "Layer" 100 NORMAL-MODE)))
)
(gimp-image-add-layer background-image new-layer -1)
(gimp-image-set-active-layer background-image new-layer)
(gimp-edit-paste new-layer TRUE)
(gimp-layer-set-offsets new-layer x-pos y-pos)
(gimp-floating-sel-anchor (car (gimp-image-get-active-layer background-image)))
)
(gimp-image-flatten background-image)
(gimp-file-save RUN-NONINTERACTIVE background-image (car (gimp-image-get-active-layer background-image)) output-file output-file)
(gimp-image-delete input-image)
(gimp-image-delete background-image)
))
(define (filename-from-path path)
(car (reverse (strbreakup path "\\")))
)
(define (basename-from-filename file-name)
(car (strbreakup file-name "."))
)
(define (center-on-background-batch background-file 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"))
)
(center-on-background background-file file-name output-filename)
)
(set! files (cdr files))
)
))
(let* (
(input-image (car (gimp-file-load RUN-NONINTERACTIVE input-file input-file)))
(background-image (car (gimp-file-load RUN-NONINTERACTIVE background-file background-file)))
(input-layer (car (gimp-image-get-active-layer input-image)))
(bg-width (car (gimp-image-width background-image)))
(bg-height (car (gimp-image-height background-image)))
(input-width (car (gimp-image-width input-image)))
(input-height (car (gimp-image-height input-image)))
(x-pos (/ (- bg-width input-width) 2))
(y-pos (/ (- bg-height input-height) 2))
)
(gimp-edit-copy input-layer)
(let* (
(new-layer (car (gimp-layer-new background-image bg-width bg-height RGBA-IMAGE "Layer" 100 NORMAL-MODE)))
)
(gimp-image-add-layer background-image new-layer -1)
(gimp-image-set-active-layer background-image new-layer)
(gimp-edit-paste new-layer TRUE)
(gimp-layer-set-offsets new-layer x-pos y-pos)
(gimp-floating-sel-anchor (car (gimp-image-get-active-layer background-image)))
)
(gimp-image-flatten background-image)
(gimp-file-save RUN-NONINTERACTIVE background-image (car (gimp-image-get-active-layer background-image)) output-file output-file)
(gimp-image-delete input-image)
(gimp-image-delete background-image)
))
(define (filename-from-path path)
(car (reverse (strbreakup path "\\")))
)
(define (basename-from-filename file-name)
(car (strbreakup file-name "."))
)
(define (center-on-background-batch background-file 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"))
)
(center-on-background background-file file-name output-filename)
)
(set! files (cdr files))
)
))
Możesz tym zastąpić poprzedni plik (nazwa pliku nie gra roli, liczy się tylko rozszerzenie, musi być "scm").
możliwe, że "gimp", będzie u Ciebie poleceniem nie rozpoznanym, albo dodać do zmiennej PATH, albo wywoływać całą ścieżkę:
Kod:
"C:\Program Files\GIMP 2\bin\gimp-2.10.exe"
To akurat łatwo sprawdzić, bo jeśli wpiszesz we wierszu poleceń powyższe polecenie, to otworzy się gimp:
Kod:
Microsoft Windows [Version 10.0.19045.4894]
(c) Microsoft Corporation. Wszelkie prawa zastrzeżone.
C:\Users\ziomi\Documents\pictures>"C:\Program Files\GIMP 2\bin\gimp-2.10.exe"
(c) Microsoft Corporation. Wszelkie prawa zastrzeżone.
C:\Users\ziomi\Documents\pictures>"C:\Program Files\GIMP 2\bin\gimp-2.10.exe"
Jak uruchomić wiersz poleceń? otwórz Menu Start, wpisz "cmd", pojawi się program "Wiersz poleceń", to ten. Takie czarne okienko z biały tekstem.
Ale można uruchomić też konsole przez wpisanie "cmd", w pasek adresu (tam gdzie się wyświetla jaki katalog otwierasz)
Czyli całe polecenie w systemie Windows będzie wyglądać tak:
Kod:
"C:\Program Files\GIMP 2\bin\gimp-2.10.exe" -i -b "(center-on-background-batch \"tlo.png\" \"input\\*.jpg\" \"output\" )" -b "(gimp-quit 0)"
Tu jedyne na co trzeba zwrócić uwagę, to jak podajesz nazwę katalogów, to trzeba pisać \\ (podwójny backslash, bo to Winndows).
Pojawi się drugie okno z wynikami polecenia.