It is currently Sun Aug 16, 2026 3:25 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: Request: Update scripts
PostPosted: Wed Sep 04, 2013 10:31 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jul 21, 2012
Posts: 103
Hi to everyone.
Is possible update two interesting scripts for gimp2.8?
http://gimpfr.org/pub/scripts-2.2/alan_ ... s-view.scm
and
http://gimpfr.org/pub/scripts-2.2/alan_ ... -align.scm
Thanks.

_________________
Image


Last edited by d4rkheart on Thu Sep 05, 2013 7:16 am, 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: Request: Update scripts
PostPosted: Wed Sep 04, 2013 10:46 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
They probably were useful scripts back in the day (circa gimp 2.2 - 2.4)
Today: First script functionality is realized in Shift-click on 'eye' and 'link' icons to show/hide/link/unlink all layers/current layer.
Second script has become the Align Tool.


Top
 Post subject: Re: Request: Update scripts
PostPosted: Wed Sep 04, 2013 10:59 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jul 21, 2012
Posts: 103
yes, but first script is interesting because you can make visible automatically the first, third, fifth, seventh, ninth layers hiding the others layers or vice versa (second,fourth, sixth, eighth, tenth..etc), with second script you can change align pixel, see image...
Attachment:
a.png
a.png [ 14.9 KiB | Viewed 2918 times ]

These scripts works only on gimp 2.2.

sorry for my english.

_________________
Image


Top
 Post subject: Re: Request: Update scripts
PostPosted: Wed Sep 04, 2013 11:13 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
d4rkheart wrote:
yes, but first script is interesting because you can make visible automatically the first, third, fifth, seventh, ninth layers hiding the others layers or vice versa (second,fourth, sixth, eighth, tenth..etc), with second script you can change align pixel, see image...
Attachment:
a.png


sorry for my english.


You're right, it's not possible to hide/unhide every other layer with Shift-click.
Still don't understand what's so unique about second script. Can you define 'pixel'? Is it a selection?
As far as script goes, it moves/aligns layers. No?


Top
 Post subject: Re: Request: Update scripts
PostPosted: Wed Sep 04, 2013 11:28 am  (#5) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
d4rkheart wrote:
yes, but first script is interesting because you can make visible automatically the first, third, fifth, seventh, ninth layers hiding the others layers or vice versa (second,fourth, sixth, eighth, tenth..etc), with second script you can change align pixel, see image...
Attachment:
a.png

These scripts works only on gimp 2.2.

sorry for my english.

With the first script your can make all layers visible (save the active one) or invert the visibility of layers, but you can't from a stack of all visible layers, show only every other one. At some point you have to manually select every other layer yourself. Surprising it doesn't work in 2.8. But just a SMOP in Python (the longest bit is the registration, the rest is mostly one-liners). A good project for someone who want to start coding python scripts :) Adding an entry to select every other layer is left as an exercise.

Nothing in the second script that cannot be done with guides, the align tool, and moving a layer pixel by pixel using the cursor keys.

_________________
Image


Top
 Post subject: Re: Request: Update scripts
PostPosted: Wed Sep 04, 2013 12:19 pm  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jul 21, 2012
Posts: 103
http://imageshack.us/clip/my-videos/62/ ... zalgx.mp4/
A little video that explain utility of second script
@Ofnuts, About second script you're right but i'm laze :oops:, i search every script that make all automatically. :oops:

_________________
Image


Top
 Post subject: Re: Request: Update scripts
PostPosted: Wed Sep 04, 2013 1:24 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
But Gimp already has that in Layer->Transform->Offset (or Shift-Ctrl-O)

Q to activate Align tool, Shift-Ctrl-O to offset. Much faster, IMO


Top
 Post subject: Re: Request: Update scripts
PostPosted: Wed Sep 04, 2013 2:15 pm  (#8) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
"Layer offset" offsets the layer contents within the same layer boundaries, and the script moves the layer by changing the layer offset within the image.

_________________
Image


Top
 Post subject: Re: Request: Update scripts
PostPosted: Thu Sep 05, 2013 3:20 am  (#9) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16160
For layers-view.scm i get a
Error: (<unknown> : 68888668) eval: unbound variable: looked


Which is weird because that is in the comment block.

When i remove the comment block i get an unbound variable "image" error. :hoh

For align helper i get a
Error: (<unknown> : 69372792) eval: unbound variable: define


Must be the way the procedures are being called that causes the errors.
Deprecations?

_________________
Image


Top
 Post subject: Re: Request: Update scripts
PostPosted: Thu Sep 05, 2013 3:43 am  (#10) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16160
d4rkheart wrote:
yes, but first script is interesting because you can make visible automatically the first, third, fifth, seventh, ninth layers hiding the others layers or vice versa (second,fourth, sixth, eighth, tenth..etc), with second script you can change align pixel, see image...
Attachment:
a.png

These scripts works only on gimp 2.2.

sorry for my english.


This is not the same script you have here.
http://gimpfr.org/pub/scripts-2.2/yourg ... helper.scm
Image
(script-fu-register "script-fu-layer-set-position"
          "<Image>/Script-Fu/Layer Align/Set Position"


Can you post the contents of the script in code blocks please?

_________________
Image


Top
 Post subject: Re: Request: Update scripts
PostPosted: Thu Sep 05, 2013 4:47 am  (#11) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
Here's a diff between the original layers-view.scm and the version I made work on GIMP 2.6.7/2.8.2:

24,25d23
<    (layer-count 0)
<    (layer 0)
68,70d65
<    (layer-count 0)
<    (layer 0)
<    (boolean FALSE)
94,96d88
<    (layer-count 0)
<    (layer 0)
<    (boolean FALSE)
130c122
< (define menu _"<Image>/Layer/View/")
---
> (set! menu _"<Image>/Layer/View/")
135c127
< (define description "
---
> (set! description "
138,140c130,132
< (define authors "Alan Horkan.  ")
< (define copyrights "Alan Horkan, 2004.  Public Domain.  ")
< (define date "2004 04 02 UTC") 
---
> (set! authors "Alan Horkan.  ")
> (set! copyrights "Alan Horkan, 2004.  Public Domain.  ")
> (set! date "2004 04 02 UTC") 


and the working code:
;; layers-view.scm -*-scheme-*-

;; Alan Horkan, April 2004.  Copyright: Public Domain. 
;; You may do whatever you like with this script but please do share
;; and try to let me know if you make any interesting changes. 

;; Ideas from Jasc Paint Shop Pro 8 (same menu locations used, mostly)
;; Layers, View: Current Only; All; None; Invert; Show Link Set; Hide Link Set. 
;; Undoable view changes seem odd but i like 'em (and Paint Shop Pro does it too)

; failed to get it working using a straight list
; looked at copy-visible.scm for inspiration: answer use an array. 
; TODO learn more Scheme, read 'the Wizard book' again ;)

; ideally moving through the layer stack should be abstracted
; and the specific function passed in a parameter as needed
; again must read 'the wizard book'

(define (layers-show image boolean)
  (let* (
      (layers (gimp-image-get-layers image)) 
   (number-layers (car layers))
   (layer-array (cadr layers))
   (layer-count 0)
   (layer 0)
    )
  (gimp-image-undo-group-start image)
  ; hide all the layers, set visibilty FALSE
  (set! layer-count 0)
  (while (< layer-count number-layers)
      (set! layer (aref layer-array layer-count))
      (gimp-drawable-set-visible layer boolean)
      (set! layer-count (+ layer-count 1)))
  )
  (gimp-image-undo-group-end image)
)


(define (script-fu-layers-view-all image drawable)
  (layers-show image TRUE) ; show all the layers
  (gimp-displays-flush) ; update the display
)


(define (script-fu-layers-view-none image drawable)
  (layers-show image FALSE) ; hide all the layers
  (gimp-displays-flush) ; update the display
)

; hide all layers, then (re)show current layer
(define (script-fu-layers-view-current-only image drawable)
    (gimp-image-undo-group-start image)
    (script-fu-layers-view-none image drawable)
    ; drawable could be a channel, must check it.   
    (if (not (= 0 (car (gimp-drawable-is-layer drawable))))
        (gimp-drawable-set-visible drawable TRUE)
    )
    (gimp-displays-flush)
    (gimp-image-undo-group-end image)
)

; not the most elegant implementation but it'll do
(define (script-fu-layers-view-invert image drawable)
  (let* (
      (layers (gimp-image-get-layers image)) 
   (number-layers (car layers))
   (layer-array (cadr layers))
   (layer-count 0)
   (layer 0)
   (boolean FALSE)
    )
  (gimp-image-undo-group-start image)
  ; hide all the layers, set visibilty FALSE
  (set! layer-count 0)
  (while (< layer-count number-layers)
      (set! layer (aref layer-array layer-count))
      (if (= (car (gimp-drawable-get-visible layer)) TRUE)
          (set! boolean FALSE)
          (set! boolean TRUE)       
      )
      (gimp-drawable-set-visible layer boolean)
      (set! layer-count (+ layer-count 1)))
  )
  (gimp-image-undo-group-end image)
  (gimp-displays-flush)
)


(define (layers-view-linked image drawable boolean)
  (let* (
      (layers (gimp-image-get-layers image)) 
   (number-layers (car layers))
   (layer-array (cadr layers))
   (layer-count 0)
   (layer 0)
   (boolean FALSE)
    )
  (gimp-image-undo-group-start image)
  ; hide all the layers, set visibilty FALSE
  (set! layer-count 0)
  (while (< layer-count number-layers)
      (set! layer (aref layer-array layer-count))
      ; show/hide linked layer and hide/show the others
      (if (= FALSE (car (gimp-drawable-get-linked layer)))
          ; must use #t or #f booleans, TRUE or FALSE unrecognised by (not)
          ;(set! boolean (not boolean)) ; this isn't working quite right
          ; dirty inelegant hack because (not) wont work as expected
          (set! boolean (if (= boolean TRUE) FALSE TRUE) )
      )
      (gimp-drawable-set-visible layer boolean)
      (set! layer-count (+ layer-count 1)))
  )
  (gimp-image-undo-group-end image)
)

(define (script-fu-layers-view-linked-show image drawable)
    (layers-view-linked image drawable TRUE) ; #t == TRUE
    (gimp-displays-flush)
)

(define (script-fu-layers-view-linked-hide image drawable)
    (layers-view-linked image drawable FALSE) ; #f == FALSE
    (gimp-displays-flush)
)
; this doesn't make as much sense as it does in Paint Shop Pro
; it has many seperate numbered link sets, gimp allows only 1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define menu _"<Image>/Layer/View/")
;(set! menu _"<Image>/Layer/Show ")
;; uncomment above line to move (Show) All/None up to the Layer menu. 

;; append/prepend description(s) to about string. 
(define description "
With sincere thanks to Jasc Paint Shop Pro 8 for the inspiration.  "
)
(define authors "Alan Horkan.  ")
(define copyrights "Alan Horkan, 2004.  Public Domain.  ")
(define date "2004 04 02 UTC") 


(script-fu-register "script-fu-layers-view-current-only"
    _"<Image>/Layer/View/_Current Only"
    (string-append "Show only the current Layer, hide all other layers.  " description)
    authors copyrights date "" ; strings set using variables, see above
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
)

(script-fu-register "script-fu-layers-view-all"
    (string-append menu _"_All")
    (string-append "Show All Layers.  Sets every layer to visible.  " description)
    authors copyrights date ""
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
)

(script-fu-register "script-fu-layers-view-none"
    (string-append menu _"_None")
    (string-append "Show None of the Layers.  Hides every layer.  " description)
    authors copyrights date ""
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
)

(script-fu-register "script-fu-layers-view-invert"
    _"<Image>/Layer/View/_Invert"
    "Invert the visibility of all Layers. 
If a layer is showing, it gets hidden and if a layer is hidden it will be shown.  "
    authors copyrights date "" ; strings set using variables, see above
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
)


;; the names "Link Set Show" and "Link Set Hide" are only a workaround
;; so the two menu items will be beside each other sorted alphabetically sorted 

(script-fu-register "script-fu-layers-view-linked-show"
    _"<Image>/Layer/View/Link Set _Show"
    (string-append "Show Link Set.  Show only the linked layers and hide all other layers.  " description)
     
    authors copyrights date ""
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
)

(script-fu-register "script-fu-layers-view-linked-hide"
    _"<Image>/Layer/View/Link Set _Hide" ; sorted, beside link set show
    (string-append "Hide Link Set.  Hide only the linked layers and show all other layers.  " description)     
    authors copyrights date ""
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
)


Kevin


Top
 Post subject: Re: Request: Update scripts
PostPosted: Thu Sep 05, 2013 4:57 am  (#12) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
Not to be pedantic, but if you change the code, you should add a comment about this (and maybe chnage the script date...). Right now the Internet will have to manage two versions of the script that only experts can distinguish...

_________________
Image


Top
 Post subject: Re: Request: Update scripts
PostPosted: Thu Sep 05, 2013 5:05 am  (#13) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
ofnuts wrote:
Not to be pedantic, but if you change the code, you should add a comment about this (and maybe change the script date...). Right now the Internet will have to manage two versions of the script that only experts can distinguish...


I thought you'd all come to the conclusion that it was pointless and that the functionality was now in GIMP anyway ;) or even better, in one of your Python scripts.

Although I made it not error, it probably needs re-thinking in the light of layer-groups and I don't want to take any responsibility for it.

Kevin


Top
 Post subject: Re: Request: Update scripts
PostPosted: Thu Sep 05, 2013 5:06 am  (#14) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16160
ofnuts wrote:
Not to be pedantic, but if you change the code, you should add a comment about this (and maybe chnage the script date...). Right now the Internet will have to manage two versions of the script that only experts can distinguish...


This is probably a wise idea.

_________________
Image


Top
 Post subject: Re: Request: Update scripts
PostPosted: Thu Sep 05, 2013 6:04 am  (#15) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
paynekj wrote:
ofnuts wrote:
Not to be pedantic, but if you change the code, you should add a comment about this (and maybe change the script date...). Right now the Internet will have to manage two versions of the script that only experts can distinguish...


I thought you'd all come to the conclusion that it was pointless and that the functionality was now in GIMP anyway ;) or even better, in one of your Python scripts.

Although I made it not error, it probably needs re-thinking in the light of layer-groups and I don't want to take any responsibility for it.

Kevin


This has nothing to do with the current (perceived) usefulness of the thing: ) After all they number Windows versions to identify them... :)

_________________
Image


Top
 Post subject: Re: Request: Update scripts
PostPosted: Thu Sep 05, 2013 7:21 am  (#16) 
Offline
GimpChat Member
User avatar

Joined: Jul 21, 2012
Posts: 103
Rod wrote:
This is not the same script you have here.
http://gimpfr.org/pub/scripts-2.2/yourg ... helper.scm
[ Image ]
(script-fu-register "script-fu-layer-set-position"
          "<Image>/Script-Fu/Layer Align/Set Position"


Can you post the contents of the script in code blocks please?

You're right Rod, sorry for the inconvenient, i've corrected second link.
This is the code, i'm sorry :oops: :(
;; layer-align.scm -*-scheme-*-
;; adapted from
;; file-place.scm -*-scheme-*-
;; see file-place for more info

;; when I'm done I'll put this in the Public Domain
;; until then this is Copyright Alan Horkan
;; you may not modify or distribute it, for personal use only. 
;; feel free to remind me. 

;; TODO NEEDS more testing and a lot of cleanup but it works

(define (script-fu-layer-align image drawable horizontal x-offset vertical y-offset) 
  (let* (
;;    (image2 (car (gimp-file-load 1 file2 file2)))

    (height2 (car (gimp-drawable-height drawable)))
    (width2 (car (gimp-drawable-width drawable)))

    (height (car (gimp-image-height image)))
    (width (car (gimp-image-width image)))

    ;; layer type is based on the current image, not the layer being placed
    (layer-type (car (gimp-drawable-type-with-alpha drawable)))
   
    ;; lazy fix(es) for gimp 2, makes keeping back compatibility easier
    (RGBA_IMAGE RGBA-IMAGE) ; no longer needed
    )

    (gimp-image-undo-group-start image) ;; make undoable

    ;; flatten the image in case it has more than one layer
;;    (gimp-image-flatten image2)
    ;; now get the drawable
;;    (set! drawable2 (car (gimp-image-get-active-drawable image2)))

    ;; create a new layer, set the file name as the layer name 
;;    (set! layer-one (car (gimp-layer-new image width2 height2 layer-type layer-name 100 NORMAL)))

;; really should check if it is a layer first
(set! layer-one drawable)


    ;; offsets for the layer
    (set! x-offset x-offset)
    (set! y-offset y-offset)

;; TODO rewrite to use cond instead of if statement
    ;; Horizontal
    ;; current position + x-offset (same as top edge + x-offset)
    (if (= 0 horizontal) (set! x-offset (+ x-offset)))
    ;; left edge + x-offset (same as current position + x-offset)
    (if (= 1 horizontal) (set! x-offset (+ x-offset)))
    ;; centre, the usual defualt.  same as cut & paste or drag & drop layer
    (if (= 2 horizontal) (set! x-offset (+ x-offset (/ (- width width2) 2))))
    ;; right edge
    (if (= 3 horizontal) (set! x-offset (+ x-offset (- width width2))))     

    ;; Vertical
    ;; current position + x-offset (same as top edge + y-offset)
    (if (= 0 vertical) (set! y-offset (+ y-offset)))
    ;; top edge + y-offset (same as current position + y-offset)
    (if (= 1 vertical) (set! y-offset (+ y-offset)))
    ;; centre, the usual defualt.  same as cut & paste or drag & drop layer
    (if (= 2 vertical) (set! y-offset (+ y-offset (/ (- height height2) 2))))
    ;; bottom edge
    (if (= 3 vertical) (set! y-offset (+ y-offset (- height height2))))     

    ;; offset the layer, finally
    (gimp-layer-set-offsets layer-one x-offset y-offset)

    (gimp-image-undo-group-end image)
    (gimp-displays-flush)
    ) ; close the let statement
)



(set! menu-item _"<Image>/Layer/Align Layer...") ; old name

(script-fu-register "script-fu-layer-align"
    menu-item
;; Help Description
"Takes the current layer and re aligns it. 
Alignment is based on the image size.  "

    "Alan Horkan.  " ; author(s)
;; when finished will be Public Domain.  not yet
    "Alan Horkan, 2004.  Copyright " ; rights 
    "2004 08 12 UTC" ; date
    "" ; supports all image types 
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0 ; is this even necessary?

    ;; Offsets. 
    ;; Horizontal:  [ Current Position     ] [ 0   ] pixels
    ;;   Vertical:  [ Current Position     ] [ 0   ] pixels
    SF-OPTION _"Horizontal"  '(
        ;_"None                                              "  ; 0
        _"Current Position                                  "  ; 0
        _"Left Edge                                         "  ; 1
        _"Centre                                            "  ; 2
        _"Right Edge                                        "  ; 3
    )
    SF-ADJUSTMENT _"pixels" '(0 -1000 1000 1 10 0 1) ; no slider
    SF-OPTION _"Vertical"  '(
        ;_"None                                              "  ; 0
        _"Current Position                                  "  ; 0
        _"Top Edge                                          "  ; 1
        _"Centre                                            "  ; 2
        _"Bottom Edge                                       "  ; 3
    )     
    SF-ADJUSTMENT _"pixels" '(0 -1000 1000 1 10 0 1) ; no slider
)

;; TODO I have no idea if Current Position is any different from Left/Top Edge
;; Need to find out, documentation was too vague and cannot tell from testing

_________________
Image


Top
 Post subject: Re: Request: Update scripts
PostPosted: Thu Sep 05, 2013 7:44 am  (#17) 
Offline
GimpChat Member
User avatar

Joined: Jul 21, 2012
Posts: 103
paynekj, with your code only link set show doesn't work correctly but for me is perfect, thanks for update. I'm sorry for all my requests, i don't know how to write scripts/plug-ins and I ask here because i'm sure to find best scripters, thanks for great work of everyone.

_________________
Image


Top
Post new topic Reply to topic  [ 17 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group