[Gimp-user] How to import Photoshop .pat files?

Alec Burgess buralex at gmail.com
Tue Jun 2 22:49:30 PDT 2009


I was following along as did Akana - I found two "Photoshop pattern 
files" one alleged to contain 162 patterns, the other 109 patterns.

Also found this plugin by Googling [use photoshop patterns in gimp]:
http://registry.gimp.org/node/10879#comment-872
I needed the windows version noted in the comments: 
http://registry.gimp.org/node/11003 (by schumaml -October 30, 2008)

With the EXE dropped in my plugins folder and after restarting GIMP I 
can now open the .PAT PS-pattern files by drag and drop from Windows 
Explorer. They are opened as a multiple layer file (apparently one layer 
per pattern).

I now need to write out all layers as individual GIMP .pat files ....
As an experiment I dragged one of the layers to a new image and did 
[Image-Autocrop], then [Save as ...]  into the Patterns folder (actually 
a subfolder thereof) as testpattern.pat (it exports, requests flattening 
and a name)

After refreshing Gimp patterns - the saved pattern *IS* available in the 
Patterns dialog - YIPPEE!

To get them created individually it looks like [Filters-Animation-Save 
Layers] does the trick. If renumbering make sure to include enough ~'s 
to cover total number of pattern files being written and specify an 
extension] eg:
"<path-to-patterns-subfolder>/devart_PS_pats_~~~.pat" (If insufficient 
~'s in the file-spec an error is generated.
This is "script-fu-save-anim-layers" by Saul Goode 3/11/2008 - not sure 
if it "came-with" GAP or I got it somewhere else?

Ok ... this "sort-of" worked :-(
I've now got 162 files in my sub-folder of patterns directory (each 2.0 
MB) and when I do refresh in pattern dialog all these appear to be 
loaded. I do get an error showing in the error console:
"Failed to load data: Failed to open file 'D:\Data 
Files\Gimp-2.x_resources\patterns\Photoshop patterns - 
converted\ademmm.deviantart.com': Permission denied"

I'm not sure whether above error really "matters" - I got the same error 
on my manually created pattern described  above ...

However ... the patterns created don't seem to be the individual layers 
- they are all sized 526x1024 and contain multiple images - what you 
would see if you merged visible with (I think) one fewer layers visible 
each time.

Any suggestions as to how to get the job finished? ie. each layer needs 
to be cropped I think.
I guess this needs a new script or tweaks to Saul Goode's 
"script-fu-save-anim-layers" but unfortunately I have zero ability in 
that area.

I've include the source of  "script-fu-save-anim-layers"below my sig in 
case its helpful ...

Akkana Peck (akkana at shallowsky.com) wrote (in part)  (on 2009-06-02 at
23:41):
>
>  DJ writes:
>  > > Yes and no. There is also the Patterns Dialog (see more below).
>  [ lots more info about where to view your GIMP patterns,
>   but not on how to import these particular patterns. ]
>
>  The problem in this case may be that a lot of those patterns on
> 
http://www.smashingmagazine.com/2009/02/12/the-ultimate-collection-of-free-photoshop-patterns/
>  aren't GIMP compatible. For instance, I tried the "animal prints" one,
>  http://redheadstock.deviantart.com/art/Animal-Prints-PS-Patterns-37342057
>  and although it supposedly includes 18 patterns, I got a zip file
>  that expanded to just one file, SS-animalprints-patterns.pat.
>  If I put that file in ~/.gimp-2.6/patterns/ it's ignored, and if I
>  try to open the file in GIMP I get "GIMP pattern plug-in could
>  not open image".  I get the same for the brick textures pattern.
>
>  Has GIMP's support of PS patterns changed?  The animal print page
>  says it should be compatible with GIMP 2.2.6+.

-- 
Regards ... Alec   (buralex at gmail & WinLiveMess - alec.m.burgess at skype)

source of: save-anim-layers.scm  

; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.

;; Command is installed in "Filters->Animations->Save layers..."
;;
;; A template string should be provided which fits the form: prefix~~~~.ext
;; where prefix is a character string (optionally null).
;;       ~~~~ represents the digits of the frame number, one ~ per digit
;;       ext is the filename extension (which also specifies the format)
;; the tildas are optional and four digits will be assumed if omitted.
;; an extension of .png is assumed if one is not provided
;; the period is significant, if PNG is not to be assumed
;;
;; A checkbox provides the option of using the layernames for the
;; filenames. The extension given in the template is used to determine
;; the file type. Animation settings (delay and frame disposal) are not
;; included as part of the filename.
;;
;; When saving to GIF files, the GIMP's default values are used to
;; convert to INDEXED mode (255 color palette, no dithering).
;; Note: this is done on a layer-by-layer basis, so more colors may result
;; than if the entire image were converted to INDEXED before saving.


(define (script-fu-save-anim-layers orig-image drawable
                                    template
                                    rename?)
  (define (get-all-layers img)
    (let* (
        (all-layers (gimp-image-get-layers img))
        (i (car all-layers))
        (bottom-to-top ())
        )
      (set! all-layers (cadr all-layers))
      (while (> i 0)
        (set! bottom-to-top (append bottom-to-top (cons (aref all-layers (- i 1)) '())))
        (set! i (- i 1))
        )
      bottom-to-top
      )
    )
  (define (save-layer orig-image layer name)
    (let* (
        (this-is-correct 0)
        (image)
        (buffer)
        )
      (set! buffer (car (gimp-edit-named-copy layer "temp-copy")))
      (set! image (car (gimp-edit-named-paste-as-new buffer)))
      (when (and (not (= (car (gimp-image-base-type image)) INDEXED))
                 (string-ci=? (car (last (strbreakup name "."))) "gif"))
        (gimp-image-convert-indexed image
                                    NO-DITHER
                                    MAKE-PALETTE
                                    255
                                    FALSE
                                    FALSE
                                    "")
        )
      (gimp-file-save RUN-NONINTERACTIVE image (car (gimp-image-get-active-layer image)) name name)
      (gimp-buffer-delete buffer)
      (gimp-image-delete image)
      )
    )
  (let* (
      (image nil)
      (layers nil)
      (fullname "")
      (basename "")
      (layername "")
      (format "")
      (layerpos 1)
      (framenum "")
      (settings "")
      (default-extension "png")
      (extension "png")
      (orig-selection)
      )
    (gimp-image-undo-disable orig-image)
    (set! orig-selection (car (gimp-selection-save orig-image)))
    (gimp-selection-none orig-image)
    (set! image (car (plug-in-animationunoptimize RUN-NONINTERACTIVE orig-image drawable)))

    (set! extension (strbreakup template "."))
    (set! extension (if (> (length extension) 1)
                      (car (last extension))
                      default-extension))
    (when (= (string-length extension) 0)
      (set! default-extension "png"))
    (when (= rename? TRUE)
      (set! format (strbreakup template "~"))
      (if (> (length format) 1)
        (begin
          (set! basename (car format))
          (set! format (cdr format))
          (set! format (cons "" (butlast format)))
          (set! format (string-append "0" (unbreakupstr format "0")))
          )
        (begin
          (set! basename (car (strbreakup template ".")))
          (set! format "0000")
          )
        )
      )
    (set! layers (get-all-layers image))
    (while (pair? layers)
      (if (= rename? TRUE)
        (begin
          (set! framenum (number->string layerpos))
          (set! framenum (string-append
                (substring format 0 (- (string-length format)
                                       (string-length framenum))) framenum))
          (set! fullname (string-append basename framenum))
          )
        (begin
          (set! fullname (car (strbreakup
                           (car (gimp-drawable-get-name (car layers))) "(")))
          (gimp-drawable-set-name (car layers) fullname)
          (set! fullname (car (gimp-drawable-get-name (car layers))))
          )
        )
      (set! fullname (string-append fullname "." extension))
      (save-layer image (car layers) fullname)
      (set! layers (cdr layers))
      (set! layerpos (+ layerpos 1))
      )
    (gimp-image-delete image)
    (gimp-selection-load orig-selection)
    (gimp-image-remove-channel orig-image orig-selection)
    (gimp-image-undo-enable orig-image)
    )
  )

(script-fu-register "script-fu-save-anim-layers"
 "<Image>/Filters/Animation/S_ave layers..."
 "Save each layer to a file."
 "Saul Goode"
 "Saul Goode"
 "3/11/2008"
 ""
 SF-IMAGE    "Image"    0
 SF-DRAWABLE "Drawable" 0
 SF-STRING "Name Template (~ replaced by layer position)" "frame_~~~~.gif"
 SF-TOGGLE "Rename (ex: 'frame__0001')" TRUE
 )


-------------- next part --------------
An HTML attachment was scrubbed...
URL: /lists/gimp-user/attachments/20090603/142a8952/attachment-0001.html 


More information about the Gimp-user mailing list