It is currently Sat Jul 06, 2024 4:33 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: deep-float-copy.scm error in gimp 2.8
PostPosted: Tue Apr 25, 2017 3:04 pm  (#1) 
Offline
GimpChat Member

Joined: Apr 25, 2017
Posts: 7
In gimp 2.6 this script works perfectly.
In gimp 2.8.20 this script as shown below (after having had a few line changes with help prescribed from the author), works great for floating copy and cut linked layers, but will not merge down these linked layers (paste). It gives the following error:
Execution error for 'Merge Down Linked Layers (Paste)':
Error: (:1) non-list argument to append.
I'm hoping that someone can spot the cause of the error in the script:


; 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.

(define (script-fu-float-each-linked-with-retention image drawable)
(define (image-get-linked-layers image)
(let* (
(all-layers (gimp-image-get-layers image))
(i (car all-layers))
(linked '())
(tmp FALSE)
)
(set! all-layers (cadr all-layers))
(while (> i 0)
(set! tmp (car (gimp-drawable-get-linked (aref all-layers (- i 1)))))
(if (= tmp TRUE)
(set! linked (append linked (list (aref all-layers (- i 1)))))
)
(set! i (- i 1))
)
(reverse linked)
)
)
(let* (
(layers (image-get-linked-layers image))
(select '())
(layer '())
(floated '())
)
(gimp-image-undo-group-start image)
(set! select (car (gimp-selection-save image)))
(while (pair? layers)
(gimp-selection-load select)
(if (= (car (gimp-drawable-mask-bounds (car layers))) 1)
(begin
(set! floated (car (gimp-selection-float (car layers) 0 0)))
(define layer (car (gimp-layer-new-from-drawable floated image)))
(define layer2 (car (gimp-layer-new-from-drawable floated image)))
(gimp-image-remove-layer image floated)
(gimp-image-add-layer image layer2 -1)
(gimp-image-add-layer image layer -1)
(gimp-drawable-set-linked (car layers) FALSE)
(gimp-drawable-set-linked layer TRUE)
(gimp-layer-set-mode layer (car (gimp-layer-get-mode (car layers))))
(gimp-layer-set-mode layer2 (car (gimp-layer-get-mode (car layers))))
(gimp-image-merge-down image layer2 EXPAND-AS-NECESSARY)
)
)
(set! layers (cdr layers))
)
(gimp-selection-load select)
(gimp-image-remove-channel image select)
(gimp-image-undo-group-end image)
(gimp-displays-flush)
)
)

(define (script-fu-float-each-linked image drawable)
(define (image-get-linked-layers image)
(let* (
(all-layers (gimp-image-get-layers image))
(i (car all-layers))
(linked '())
(tmp FALSE)
)
(set! all-layers (cadr all-layers))
(while (> i 0)
(set! tmp (car (gimp-drawable-get-linked (aref all-layers (- i 1)))))
(if (= tmp TRUE)
(set! linked (append linked (list (aref all-layers (- i 1)))))
)
(set! i (- i 1))
)
(reverse linked)
)
)
(let* (
(layers (image-get-linked-layers image))
(select '())
(layer '())
(floated '())
)
(gimp-image-undo-group-start image)
(set! select (car (gimp-selection-save image)))
(while (pair? layers)
(gimp-selection-load select)
(if (= (car (gimp-drawable-mask-bounds (car layers))) 1)
(begin
(set! floated (car (gimp-selection-float (car layers) 0 0)))
(define layer (car (gimp-layer-new-from-drawable floated image)))
(gimp-image-remove-layer image floated)
(gimp-image-add-layer image layer -1)
(gimp-drawable-set-linked (car layers) FALSE)
(gimp-drawable-set-linked layer TRUE)
(gimp-layer-set-mode layer (car (gimp-layer-get-mode (car layers))))
)
)
(set! layers (cdr layers))
)
(gimp-selection-load select)
(gimp-image-remove-channel image select)
(gimp-image-undo-group-end image)
(gimp-displays-flush)
)
)

(define (script-fu-merge-each-linked image drawable)
(define (image-get-layers image)
(let* (
(all-layers (gimp-image-get-layers image))
(i (car all-layers))
(layers 0)
)
(set! all-layers (cadr all-layers))
(while (> i 0)
(set! layers (append layers (list (aref all-layers (- i 1)))))
(set! i (- i 1))
)
(reverse layers)
)
)
(define (image-get-linked-layers image)
(let* (
(all-layers (gimp-image-get-layers image))
(i (car all-layers))
(linked '())
(tmp FALSE)
)
(set! all-layers (cadr all-layers))
(while (> i 0)
(set! tmp (car (gimp-drawable-get-linked (aref all-layers (- i 1)))))
(if (= tmp TRUE)
(set! linked (append linked (list (aref all-layers (- i 1)))))
)
(set! i (- i 1))
)
(reverse linked)
)
)
(let* (
(layers (image-get-layers image))
(linked (image-get-linked-layers image))
(layer '())
(mode '())
)
(gimp-image-undo-group-start image)
(while (pair? linked)
(set! layer (member (car linked) layers))
(if (pair? (cdr layer))
(begin
(set! layer (cadr layer))
(set! mode (car (gimp-layer-get-mode layer)))
(gimp-drawable-set-visible (car linked) TRUE)
(gimp-drawable-set-visible layer TRUE)
(set! layer (car (gimp-image-merge-down image (car linked) EXPAND-AS-NECESSARY)))
(gimp-drawable-set-linked layer TRUE)
(gimp-layer-set-mode layer mode)
)
)
(set! linked (cdr linked))
)
(gimp-image-undo-group-end image)
(gimp-displays-flush)
)
)

(script-fu-register "script-fu-float-each-linked"
"<Image>/Script-Fu/Multi-Layer-Cut-Copy-Paste/Float Linked Layers (Cut)"
"Float the selection on each linked layer"
"Saul Goode"
"Saul Goode"
"12/16/2006"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)

(script-fu-register "script-fu-float-each-linked-with-retention"
"<Image>/Script-Fu/Multi-Layer-Cut-Copy-Paste/Float Linked Layers (Copy)"
"Float the selection on each linked layer - retaining a copy in the original. Derived from Saul Goode's Float Linked Layers from 12/16/2006"
"Michael B. McLaughlin"
"Michael B. McLaughlin"
"04/03/2010"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)

(script-fu-register "script-fu-merge-each-linked"
"<Image>/Script-Fu/Multi-Layer-Cut-Copy-Paste/Merge Down Linked Layers (Paste)"
"Merge each linked layer with the one beneath it"
"Saul Goode"
"Saul Goode"
"12/16/2006"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)
--------------------------------------------------------------------------------------
The changes I made were as given.
I quote the comment on the page from which the changes were made:
"Working with some modifications:
Than you for this useful script!

It needed some corrections to work with Gimp 2.8.4 (Ubuntu 13.04)

First i got "non-list argument to append" -errors (like Hymer did)
They got fixed by changing all
(linked 0), (select 0), (layer 0), (floated 0) and (mode 0) -lines
to
(linked '()), (select '()), (layer '()), (floated '()) and (mode '()) -lines. (with tip from saulgoode) [also restarted GIMP after altering the script]
Not tested this widely, but at least I used the script to copy-paste a multilayer picture once."


Last edited by adbeik15 on Wed Apr 26, 2017 10:17 pm, edited 1 time in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: deep-float-copy.scm error in gimp 2.8
PostPosted: Wed Apr 26, 2017 8:34 pm  (#2) 
Offline
Global Moderator
User avatar

Joined: Apr 01, 2012
Posts: 7746
Location: On the other side of this screen
Make it easier ;) Highlight the areas you changed so coders can check you haven't made any errors first.

_________________


Top
 Post subject: Re: deep-float-copy.scm error in gimp 2.8
PostPosted: Thu Apr 27, 2017 7:32 am  (#3) 
Offline
GimpChat Member

Joined: Apr 25, 2017
Posts: 7
Sallyanne thank you for the suggestion. I added the changes that I made according to the directions shown. As a newbie to gimp chat I was unable to highlight the script in the editor, but the changes may be highlighted very easily using the find feature of the browser.


Top
 Post subject: Re: deep-float-copy.scm error in gimp 2.8
PostPosted: Thu Apr 27, 2017 12:17 pm  (#4) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2439
Try this 'mod' version but with the caveat that I am not too sure it does what you want it to do. (and also no expert on writing scripts)

All it is, is Saule Goodes code from merge-linked.scm planted in the deep-float-copy.scm

Both scripts attached, remember to unzip. Usual guarantees, there are none ;)

EDIT:
Back to the drawing board, it merges but not the way described here: http://registry.gimp.org/node/24270 Left the merge linked on, it might be of some use.


Attachments:
sg-merge-linked.scm.zip [973 Bytes]
Downloaded 181 times

_________________
Image
Top
 Post subject: Re: deep-float-copy.scm error in gimp 2.8
PostPosted: Thu Apr 27, 2017 2:08 pm  (#5) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
Does your image have layer-groups? because they need to be handled as a special case.


Top
 Post subject: Re: deep-float-copy.scm error in gimp 2.8
PostPosted: Thu Apr 27, 2017 2:24 pm  (#6) 
Offline
GimpChat Member

Joined: Apr 25, 2017
Posts: 7
The script works on all linked layers but not on group layers.


Top
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Deep Dreamed Tiger.

33

No new posts DeOldify A Deep Learning based project for colorizing old images

2

No new posts Attachment(s) Path copy rotate shift plus + Path copy rotate shift walk Play

79

No new posts How to merge down layer copy

2

No new posts Attachment(s) Path Copy Rotate Shift Plus

18



* Login  



Powered by phpBB3 © phpBB Group