Hi Nelo, as an AI language model would claim, you are
right.
There is
not a
simple way
to convert Gimp brush .
gbr to Adobe PhotoShop brush .
abrBeginning by a
negative sentence is an
obvious shibboleth that does
not help.
Three teams of developpers of the
softwares quoted in #2 were able to design an .abr
reader probably in a compiled high level language such as C++ or C.
However they
all decided to
not publish
the feature of
writing a brush in .abr format.
What could we expect with the
prehistoric interpreted language Script-Fu, mainly when the
problem of the writing of an .abr is
not technical?
Exporting a grayscale .gbr brush as .png in Gimp Script-FuAttachment:
ExportGbrToPng.png [ 143.29 KiB | Viewed 1374 times ]
Anyway in the following version of the export of .gbr to .png, there is
no need to close
manually the .gbr by Ctrl+W.
Introducing Export-gbr-to-png 2.0
; Gimp Script-Fu exports brush .gbr as .png with the idea to import .png in PhotoShop to build brush .abr
(define (Export-gbr-to-png fileGbr) ; Export brush .gbr as .png
(let* ( (vPath (PathSplit fileGbr)) ; See KodiSave.scm
(pathPic (vector-ref vPath 1)) ; 0-based element in the vector
(filename (vector-ref vPath 2))
(lstFile (strbreakup filename ".")) ; split the filename into the basename and the fileExt
(basename (car lstFile))
(filePng (string-append pathPic DIR-SEPARATOR basename ".png"))
(imgPng (car (gimp-image-new 1 1 GRAY)))
(layPng (car (gimp-layer-new imgPng 1 1 GRAY-IMAGE "layer main" 100 LAYER-MODE-NORMAL-LEGACY)))
(imgGbr (car (gimp-file-load-layer 1 imgPng fileGbr))) ; load the brush .gbr
)
(gimp-image-insert-layer imgPng layPng 0 0) ; top of layer stack
(gimp-image-insert-layer imgPng imgGbr 0 0) ; insert .brush as layer
(script-fu-util-image-resize-from-layer imgPng imgGbr) ; resize .png to the brush size
(gimp-layer-resize-to-image-size layPng) ; also its layer
(set! layPng (car (gimp-image-flatten imgPng))) ; merge layer .png and layer .gbr
(file-png-save RUN-NONINTERACTIVE imgPng layPng filePng filePng 0 9 0 0 0 0 0) ; save as .png
(gimp-image-clean-all imgPng) ; clean-up
(gimp-image-delete imgPng) ; you can close the exported .png
(displayln (string-append "Export-gbr-to-png SUCCESSFULLY exported \"" basename ".gbr\" to " filePng))
) )
Also, copy and paste the function
PathSplit from KodiSave.scm or hereafter enclosed:
; (PathSplit "")
; Error: 4500 PathSplit: the path cannot be empty
; (PathSplit "C")
; Error: 4510 PathSplit: the path should have more than one character
; (PathSplit "NoDrive")
; Error: 4520 PathSplit: the path contains an unsupported separator of folders
; (PathSplit "C:")
; #("C:" "" "")
; (PathSplit "C:\\")
; #("C:" "" "")
; (PathSplit "C:\\Tool\\Gimp\\forum\\GimpChat\\SaveXcf-ExportPng")
; #("C:" "C:\\Tool\\Gimp\\forum\\GimpChat" "SaveXcf-ExportPng")
; (PathSplit "C:\\Tool\\Gimp\\forum\\GimpChat\\SaveXcf-ExportPng\\")
; #("C:" "C:\\Tool\\Gimp\\forum\\GimpChat" "SaveXcf-ExportPng")
; (PathSplit "C:\\Tool\\Gimp\\forum\\GimpChat\\SaveXcf-ExportPng\\_GamerOfThrone1.png")
; #("C:" "C:\\Tool\\Gimp\\forum\\GimpChat\\SaveXcf-ExportPng" "_GamerOfThrone1.png")
; (PathSplit "C:\Tool\Gimp\forum\GimpChat\SaveXcf-ExportPng\TV Shows\Gamer of Throne (2011)\_GamerOfThrone1.png")
; Error: 4520 PathSplit: the path contains an unsupported separator of folders
; (PathSplit "C:/Tool/Gimp/forum/GimpChat/SaveXcf-ExportPng/TV Shows/Gamer of Throne (2011)/_GamerOfThrone1.png")
; Error: 4520 PathSplit: the path contains an unsupported separator of folders
; Split a full path returning a vector containing: the drive such as "C:", the parent folder and the basename:
; If the path ends by a filename, the basename if this filename. Otherwise the basename is the last folder of the path.
; string
(define (PathSplit path)
(let* ( (lenDir (string-length path)))
(if (zero? lenDir) (throw "4500 PathSplit: the path cannot be empty"))
(if (< lenDir 2) (throw "4510 PathSplit: the path should have more than one character"))
(let* ( (idxLast (- lenDir 1)) ; index of the last character in the path
(isLastSep? (char=? (string-ref path idxLast) (string-ref DIR-SEPARATOR 0)))
(strDir (if isLastSep? ; If the path ends with the DIR-SEPARATOR
(substring path 0 idxLast) ; Remove ending DIR-SEPARATOR
path ; else keep the path unchanged
) ) )
(if isLastSep? (set! idxLast (- idxLast 1))) ; Since the last DIR-SEPARATOR has been removed, decrement idxLast
(if (char=? (string-ref strDir idxLast) #\:) ; Does the path end with the drive separator ":"?
(vector strDir "" "") ; The parent of the root folder is the root folder. The current folder is empty
(let* ( (lstPath (strbreakup strDir DIR-SEPARATOR)) ; Otherwise split the path removing each DIR-SEPARATOR
(lstDir (reverse (cdr (reverse lstPath)))) ; remove the last folder from lstPath
(parent (if (zero? (length lstDir))
(throw "4520 PathSplit: the path contains an unsupported separator of folders")
(unbreakupstr lstDir DIR-SEPARATOR)) ; Rebuild the parent without the last folder
)
(basename (carDbg (last lstPath) 'PathSplit1 path)) ; basename is the last string of lstPath
(drive (carDbg lstPath 'PathSplit2 path))
)
(vector drive parent basename) ; return a vector: basename could be either the last folder or the filename.
) ) ) ) )
Run in Windows
doubling each backslash of the .gbr
full path :
(Export-gbr-to-png "C:\\Tool\\Gimp\\forum\\GimpChat\\Brush\\Chalk-02-copy.gbr")
Export-gbr-to-png SUCCESSFULLY exported "Chalk-02-copy.gbr" to C:\Tool\Gimp\forum\GimpChat\Brush\Chalk-02-copy.png
#t