Out of need I created a script and finally got it working even on 2.3.18.

Normally an animation is either done as one layer for each frame or using GIMP Animation Package one file per frame. With the first method, it is not possible to have multiple layers per frame since a layer is a frame. With the second, multiple files must be kept. While GAP is good, for simple animations it would be easier to just store each frame in one image side by side.

This script makes it where the animation is actually in a single file, each frame tiled horizontally across. The script itself simply converts the tiled animation into layers. For example, a 32x32 animation with 10 frames would be created as a 320x32 image, and the frames would be at (0,0)-(31,31),(32,0)-(63,31),etc where the left most part is the first frame. The animation can have layers. It is possible to have a certain item appear on each frame simply by creating it in one area and tiling it across with the Map->Tile plugin. When desired to export the animation, this script will simply copy the visible part of the image and cut it based on the frame size into layers automatically.

I don't know where to send this script or if it would be useful to anyone else, so it is included in this email as an attachment.
;; tile2anim.scm -*-scheme-*-
;; Converts a tiled animation to a layered animation
;; A tiled animation is one where each frame of the animation
;; is tiled across the image horizontally.  For example,
;; a 48x48 30 frame animation would be an image with the
;; size 1440x48.  Frame 1 is at (0,0)-(47,47), 2 at (48,0)-(95,47)
;; and so on
;; Version 1.2
;; Copyright (C) 2007 by Brian Vanderburg II
;; 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
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

; Internal function to create the layered animation
(define (script-fu-tile2anim img drw frameWidth)

    ; get image information
    (set! theWidth (car (gimp-image-width img)))
    (set! theHeight (car (gimp-image-height img)))
    ; create new image and layer
    (set! theImage (car (gimp-image-new theWidth theHeight RGB)))
    (set! theLayer (car (gimp-layer-new theImage theWidth theHeight RGBA-IMAGE 
    (gimp-image-add-layer theImage theLayer 0)
    (gimp-drawable-fill theLayer TRANSPARENT-FILL)
    ; copy visible portion of image
    (gimp-selection-none img)
    (if (= (car (gimp-edit-copy-visible img)) TRUE)
        (gimp-rect-select theImage 0 0 theWidth theHeight CHANNEL-OP-REPLACE 0 
        (gimp-floating-sel-anchor (car (gimp-edit-paste theLayer FALSE)))
    ; number of frames
    ; TODO: Make sure number is rounded down (4.7 = 4 frames)
    (set! frameCount (/ theWidth frameWidth))
    ; process frames
    (set! framePos 0)
    (while (< framePos frameCount)
      ; create new layer and add it to image
      (set! tmpLayer (car (gimp-layer-new theImage frameWidth theHeight 
      (gimp-image-add-layer theImage tmpLayer -1)
      (gimp-drawable-fill tmpLayer TRANSPARENT-FILL)
      ; copy
      (gimp-rect-select theImage (* framePos frameWidth) 0 frameWidth theHeight 
      (if (= (car (gimp-edit-copy theLayer)) TRUE)
          (gimp-rect-select theImage 0 0 frameWidth theHeight 
          (gimp-floating-sel-anchor (car (gimp-edit-paste tmpLayer FALSE) ) )
      (gimp-selection-none theImage)
      ; next frame
      (set! framePos (+ framePos 1))
    ; Remove old layer
    (gimp-image-remove-layer theImage theLayer)
    ; set correct image size
    (gimp-image-resize theImage frameWidth theHeight 0 0)
    ; show image
    (gimp-display-new theImage)
) ; script-fu-tile2anim

(script-fu-register "script-fu-tile2anim"
                    _"Converts a horizontal tile of frames to a layered 
                    "Brian Vanderburg II <[EMAIL PROTECTED]>"
                    "Brian Vanderburg II"
                    "August 2007"
                    "RGB*, INDEXED*, GRAY*"
                    SF-IMAGE       "Image"         0
                    SF-DRAWABLE    "Drawable"      0

                    SF-ADJUSTMENT _"Frame Width"   '(48 1 20000 1 10 0 0) )
(script-fu-menu-register "script-fu-tile2anim"
                         ; _"<Image>/Script-Fu/Animators")
Gimp-user mailing list

Reply via email to