Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; A simple script to merge seperated panels of a vertical comic.
- ; Install this script by copy pasting its contents into notepad, saving as panel-merger.scm,
- ; and putting it into GIMPs script folder (which is usually found at C\Program Files\GIMP x.x\share\gimp\x.x\scripts).
- ; Then restart GIMP or click Filters > Script-Fu > Refresh Scripts.
- ; Simply add the image of each panel of the comic to GIMP such that the 1st panel is at the top of the layer list
- ; and the last panel is at the bottom, then run this script by navigating to Image > Merge Panels, and you're done!
- ; Works best when panels are all of same height and width. Doesn't (usually) explode if they're not,
- ; just might require some manual canvas resizing or layer offsetting to fix it up.
- (define (script-fu-panel-merger imagevariable)
- (let* ( ;declare ALL the variables!
- (layercount (car (gimp-image-get-layers imagevariable)))
- (templayercount 0)
- (behindtlc 0)
- (layerlist (cadr (gimp-image-get-layers imagevariable)))
- (heightlist (cadr (gimp-image-get-layers imagevariable)))
- (tempheightvalue 0)
- (lastlayerheight 0)
- (lastlayercount 0)
- (canvaswidth (car (gimp-image-width imagevariable)))
- )
- (gimp-undo-push-group-start imagevariable) ;sets where to revert to when you hit the undo button
- (while (< templayercount layercount) ;gets height value to resize canvas to, and populates vector with list of layer heights for later
- (set! tempheightvalue (+ tempheightvalue (car (gimp-drawable-height (vector-ref layerlist templayercount)))))
- (vector-set! heightlist templayercount (gimp-drawable-height (vector-ref layerlist templayercount)))
- (set! templayercount (+ templayercount 1))
- )
- (gimp-image-resize imagevariable canvaswidth tempheightvalue 0 0) ;resizes the canvas to combined height of layers
- (set! templayercount 0)
- (while (< templayercount layercount) ;adds alpha channels to each layer
- (gimp-layer-add-alpha (vector-ref layerlist templayercount))
- (set! templayercount (+ templayercount 1))
- )
- (set! templayercount 0)
- (while (< templayercount layercount) ;resizes each layer to canvas size
- (gimp-layer-resize-to-image-size (vector-ref layerlist templayercount))
- (set! templayercount (+ templayercount 1))
- )
- (set! templayercount 1)
- (if (> layercount 1)
- (while (< templayercount layercount) ;offsets each layer by the appropiate height
- (set! lastlayerheight (+ lastlayerheight (car (vector-ref heightlist behindtlc))))
- (gimp-layer-set-offsets (vector-ref layerlist templayercount) 0 lastlayerheight)
- (set! templayercount (+ templayercount 1))
- (set! behindtlc (+ behindtlc 1))
- )
- )
- (gimp-undo-push-group-end imagevariable)
- (gimp-displays-flush)
- );paren let*
- );paren define
- (script-fu-register
- "script-fu-panel-merger"
- "Merge Panels"
- "Merges panels of a comic vertically: \
- first arrange each panel as a layer,\
- with the first panel as the first layer,\
- and so on, before running the script."
- "Anon"
- "No restrictions on use/modfication."
- "March 29th, 2017"
- ""
- SF-IMAGE "SF-IMAGE" 0
- )
- (script-fu-menu-register "script-fu-panel-merger" "<Image>/Image") ;puts "Merge Panels" under the Image menu in GIMP GUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement