It is currently 21 Jan 2018, 17:59

GIMP Scheme Fu ScriptsChange the names of script (SCM) files (Showcase | Slideshow)

Share your Scheme Fu scripts for GIMP here
User avatar
Pegleg44

Forum Member
View: Showcase | Slideshow
Topic Posts: 8/15
Posts: 43
Joined: 28 Nov 2016, 19:12
Cash on hand: 258.13 GLP
x 11
Gimp Nation

Re: Change the names of script (SCM) files

Post#8 by Pegleg44 » 18 Feb 2017, 08:44


@ Tin

What I really want to do is put all the scripts that I have into the same menu drop down box so that when I share them with others they will be able to see them all right there in one place.

So I've noticed that you have made a few scripts that I use and they are in a file menu at the top called Script-Fu. Now does that menu (Script-Fu) appear simply because you have put it in this line here:

Code: Select all

 "<Image>/Script-Fu/round-raster-for-PegLeg44 ..."    ;menu register
Here's the whole code which calls upon another script that is called "RMA_selection_blend" that is named 3 times in this script. Once after define and then after step 4 and 7.

Code: Select all

;as described in steps by PegLeg44 here:http://gimpchat.com/viewtopic.php?f=9&t=14046&p=192064#p192064
;
(define (RMA_selection_blend_sub img inLayer inGrad inRev inMethod)
  (let*
    ( (width (car (gimp-image-width img)))
	  (height (car (gimp-image-height img)))
      (selbounds (gimp-selection-bounds img))
      (inGrad (if (equal? inGrad "") (car (gimp-context-get-gradient)) inGrad))
      (origimg img)
      (origlayer inLayer)
      (img (car (gimp-image-duplicate img)))
      (inLayer (car (gimp-image-get-active-layer img)))
      (selchannel 0)
      (counter 0)
      (countto 0)
      (selsize 0)
      (slice 0)
      (errhandler (car (gimp-message-get-handler)))
	)
    
    (gimp-message-set-handler CONSOLE)
    
    (gimp-image-undo-group-start origimg)
    (gimp-image-undo-freeze img)
    (gimp-context-push)
    (gimp-context-set-gradient inGrad)
	
    (if (zero? (car selbounds)) (gimp-selection-all img))
    
    (set! selchannel (car (gimp-selection-save img)))
    
    (cond
      ( (= inMethod 0) ; Horizontal
        (set! counter (caddr selbounds))
        (set! countto (cadddr (cdr selbounds)))
        (set! selsize (- (cadddr selbounds) (cadr selbounds)))
        (while (< counter countto)
          (gimp-rect-select img (cadr selbounds) counter selsize 1 CHANNEL-OP-REPLACE FALSE 0)
          (gimp-selection-combine selchannel CHANNEL-OP-INTERSECT)
          (set! slice (cdr (gimp-selection-bounds img)))
          (if (zero? inRev)
            (gimp-edit-blend inLayer CUSTOM-MODE NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE TRUE 3 0.2 TRUE 
              (car slice) (cadr slice) (caddr slice) (cadr slice))
            (gimp-edit-blend inLayer CUSTOM-MODE NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE TRUE 3 0.2 TRUE 
              (caddr slice) (cadr slice) (car slice) (cadr slice))
           )
          (set! counter (+ counter 1))
        )
      )
      ( (= inMethod 1) ; Vartical
        (set! counter (cadr selbounds))
        (set! countto (cadddr selbounds))
        (set! selsize (- (cadddr (cdr selbounds)) (caddr selbounds)))
        (while (< counter countto)
          (gimp-rect-select img counter (list-ref selbounds 2) 1 selsize CHANNEL-OP-REPLACE FALSE 0)
          (gimp-selection-combine selchannel CHANNEL-OP-INTERSECT)
          (set! slice (cdr (gimp-selection-bounds img)))
          (if (zero? inRev)
            (gimp-edit-blend inLayer CUSTOM-MODE NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE TRUE 3 0.2 TRUE 
              (car slice) (cadr slice) (car slice) (cadddr slice))
            (gimp-edit-blend inLayer CUSTOM-MODE NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE TRUE 3 0.2 TRUE 
              (car slice) (cadddr slice) (car slice) (cadr slice 2))
          )              
          (set! counter (+ counter 1))
        )
      )
    )
     
    (if (zero? (car selbounds))
      (gimp-selection-none img)
      (gimp-selection-load selchannel)
    )

    (gimp-edit-copy inLayer)
    (gimp-floating-sel-anchor (car (gimp-edit-paste origlayer TRUE)))
    
  	(gimp-displays-flush)
	(gimp-context-pop)
  	(gimp-image-undo-thaw img)
    (gimp-image-delete img)
    
  	(gimp-image-undo-group-end origimg)
    
    (gimp-message-set-handler errhandler)
    
  )
)
(define (script-fu-round-raster-for-pegleg44 image layer 
			step4gradient
			step4reversed
			step4method
			step7gradient
			step7reversed
			step7method
			offset-x-power
         )
	
		(let* 
		   (
		   (width (car (gimp-image-width image)))
		   (height (car (gimp-image-height image)))
		   (active-vectors 0)
		   (new-layer 0)
		   (dup-layer 0)
		   (dup-layer2 0)
		   (offset-x 0)
		   )
			;(gimp-image-undo-disable image); DN = NO UNDO
			(gimp-context-push)
			(gimp-image-undo-group-start image)                   ;undo-group in one step
			
			
			;1. I turn the path to a [Selection] [From Path].
			(set! active-vectors (car (gimp-image-get-active-vectors image)))
			(gimp-image-select-item image CHANNEL-OP-REPLACE active-vectors)
			
			;2. I create a new white layer.
			(set! new-layer (car (gimp-layer-new image width height
	                           RGBA-IMAGE "new white" 100 NORMAL-MODE)))
			(gimp-drawable-fill new-layer WHITE-FILL)         ;fills background with white
			(gimp-image-insert-layer image new-layer 0 0) ;parent 0, insert layer on top position(0)				   
	
			;3. And fill the selection with black [Fill with Foreground Color].
			(gimp-edit-fill new-layer FOREGROUND-FILL)
			
			;4. And then un-select [Select] [None].
			(gimp-selection-none image)
			
			;5. Then I run the [Colors] [Threshold] on the layer (with the standard 127 and 255 setting).
			(gimp-threshold new-layer 127 255)
			
			;6. And run [Layers] [Transparency] [Color to Alpha] on it.
			(plug-in-colortoalpha 1 image new-layer '(255 255 255))
			
			;7. Then click the button [Lock Alpha Channel] at the top of the layers dockable dialog.
			(gimp-layer-set-lock-alpha new-layer TRUE)
			
			;8. Change the layer mode to [Darken Only]
			(gimp-layer-set-mode new-layer DARKEN-ONLY-MODE)
			
			;9. And finally use [Colors] [Invert] on it to make the black white.
			(gimp-invert new-layer)
			;------------------------------------------------- END OF path-to-selection-for Pegleg44
			
			;1. Run the script that you have made on the path that is already created - [Script-Fu] [path-to-selection]
			; ALREADY DONE ABOVE
			
			;2. [Layer] [Transparency] [Alpha to Selection]
			(gimp-image-select-item image CHANNEL-OP-REPLACE new-layer)
			
			;3. [Image] [Crop to Selection]
			(plug-in-autocrop 1 image new-layer)
            ;4. Run the [Select] [Selection Blend] script that RobA made with a gradient that I have created called 01RoundFull or I would prefer to select it.
			(RMA_selection_blend_sub image new-layer step4gradient step4reversed step4method)
			
			;5. [Layer] [Duplicate Layer]
			(set! dup-layer (car (gimp-layer-copy new-layer TRUE)))
			(gimp-image-insert-layer image dup-layer 0 0)
			
			;6. [Select] [All]
			(gimp-selection-all image)
			
			;7. [Select] [Selection Blend] RobA script with a different gradient (FG to BG RGB] or I will be able to select.
			(RMA_selection_blend_sub image dup-layer step7gradient step7reversed step7method)
			
			;8. [Colors] [Levels] and the far right input level field at 127
			(gimp-levels dup-layer HISTOGRAM-VALUE 0 127 1.0 0 255)
			
			
			;13. Step 9 thru 12 need to be repeated with the other X values from 2 to 256 (up to 256 would work best or 512 if you want)
			; while loop from step 9 to step 12
			(while (<= offset-x offset-x-power)
				;9. [Layer] [Duplicate Layer]
				(set! dup-layer2 (car (gimp-layer-copy dup-layer TRUE)))
				(gimp-image-insert-layer image dup-layer2 0 0)
				
				;10. Set layer mode to [Darken Only]
				(gimp-layer-set-mode dup-layer2 DARKEN-ONLY-MODE)
				
				;11. [Layer] [Transform] [Offset] X value of 1, (2, 4, 8, 16, 32, 64, 128, 256)
				(gimp-drawable-offset dup-layer2 TRUE 
												 1 ;not used as we have specifed wrap to TRUE above
												 (pow 2 offset-x)
												 0
												 )
				
				;12. [Layer] [Merge Down]
				(set! dup-layer (car (gimp-image-merge-down image dup-layer2 0)))
				
				(set! offset-x (+ offset-x 1))
			)
			
			;14. Finally the layer mode needs to be set to Screen
			(gimp-layer-set-mode dup-layer SCREEN-MODE)			
			
			
			
			
		   ;(gimp-image-undo-enable image) ;DN = NO UNDO
			(gimp-image-undo-group-end image)                     ;undo group in one step
			(gimp-context-pop)
			(gimp-displays-flush)
			
			
	    )
	
    
) ;end of define
(script-fu-register
  "script-fu-round-raster-for-pegleg44"         ;function name
  "<Image>/Script-Fu/round-raster-for-PegLeg44 ..."    ;menu register
  "Start with a Path - The Script will Change the Image Size so Use a New Canvas"       ;description
  "Tin Tran"                          ;author name
  "copyright info and description"         ;copyright info or description
  "2016"                          ;date
  "RGB*, GRAY*"                        ;mode
  SF-IMAGE      "Image" 0                   
  SF-DRAWABLE   "Layer" 0
  SF-GRADIENT   "(Step 4) Blend Selection Gradient"           ""
  SF-TOGGLE     "(Step 4) Blend Selection Reversed"           FALSE
  SF-OPTION	    "(Step 4) Blend Selection Method"		       (list "Horizontal" "Vertical")
  SF-GRADIENT   "(Step 7) Blend Selection Gradient"           ""
  SF-TOGGLE     "(Step 7) Blend Selection Reversed"           FALSE
  SF-OPTION	    "(Step 7) Blend Selection Method"		       (list "Horizontal" "Vertical")
  SF-OPTION	    "Transform Offset X upto and including"		   (list "1" "2" "4" "8" "16" "32" "64" "128" "256" "512" "1024" "2048")
)
So I would want to change the name of RMA_selection_blend to something else and make it appear in a new pull down menu in gimp. And then also make the script that calls upon it to find it.

I have a whole list of scripts that I want to put into a pull down that I will call GIMP CAD. Some of them are python and some script-fu. Can I do that? You have made some that I use and put them into a python-Fu pull down and others that you made go into Script-Fu. But I want to put them all in one.

Alan
0 x




Registered members enjoy ads-free content
User avatar
tim
Administrator
View: Showcase | Slideshow
Topic Posts: 7/15
Posts: 2071
Joined: 25 Sep 2016, 17:16
Cash on hand: 7,180.19 GLP
Bank: 42,250.25 GLP
Gender: Guy
Location: Victoria, BC
Website: https://gimplearn.net
Operating System: Windows
GIMP Version: 2.8.22
My Personal Blog
My FineArtAmerica
x 1106
x 240
Contact:
Canada

Post#9 by tim » 18 Feb 2017, 10:10


this RMA_selection_blend_sub is only internally used by this script that's why it's defined and used twice (that's why 3 occurrences).
I copied it from somewhere else, the original that provides that RMA_selection_blend is probably just called RMA_selection_blend without the _sub... i named it _sub to let me know that it's just a subroutine used internally by this script.
You can name it anything you like as long as it's valid name like words with underscores, just make sure you change them in all 3 places.
As far as where it is on the menu you can change <Image>/Script-Fu/round-raster-for-PegLeg44
to anything you like, like for example <Image>/GIMP CAD/my script 1
And GIMP will automatically create a 'GIMP CAD' menu on top and then inside that will be your 'my script 1'
0 x



aka Tin
Image gimplearn.net                                              

User avatar
Pegleg44

Forum Member
View: Showcase | Slideshow
Topic Posts: 8/15
Posts: 43
Joined: 28 Nov 2016, 19:12
Cash on hand: 258.13 GLP
x 11
Gimp Nation

Post#10 by Pegleg44 » 18 Feb 2017, 12:55


Basically I only want to change where scripts are put in the menu pull downs and the names that they are called in there.

So as long as I just change the <Image>/GIMP CAD/my script 1, then it will create the (GIMP CAD) menu and call it (my script 1) and all the other stuff can stay the same and I won't have any issues with one script calling on another one or defining or whatever. Is that correct?

The <Image>/GIMP CAD/my script 1, just names menus and the name that appears or that it is called in the menu right?

That way the register for python-fu and script-fu register will stay the same and all scripts will find other ones if they need it right?

And if the register stays the same then I won't even have to change the keyboard shortcuts that I have already set up.

If this is correct then I won't need to change the name of the SCM file at all.

If the answer is yes then I will make a copy of my scripts and plug ins and change them to try it out.

Alan
0 x




User avatar
tim
Administrator
View: Showcase | Slideshow
Topic Posts: 7/15
Posts: 2071
Joined: 25 Sep 2016, 17:16
Cash on hand: 7,180.19 GLP
Bank: 42,250.25 GLP
Gender: Guy
Location: Victoria, BC
Website: https://gimplearn.net
Operating System: Windows
GIMP Version: 2.8.22
My Personal Blog
My FineArtAmerica
x 1106
x 240
Contact:
Canada

Post#11 by tim » 18 Feb 2017, 13:05


Not sure about short cuts... but yeah that's all you need to change if you want to change menu location.
The "<Image>/GIMP CAD/my script 1" line
0 x



aka Tin
Image gimplearn.net                                              

User avatar
Pegleg44

Forum Member
View: Showcase | Slideshow
Topic Posts: 8/15
Posts: 43
Joined: 28 Nov 2016, 19:12
Cash on hand: 258.13 GLP
x 11
Gimp Nation

Post#12 by Pegleg44 » 18 Feb 2017, 18:48


Yes I changed all the scripts to be in the same directory where I can now get to them easily. Works Great! And I also changed most of the mouseover text tips that pop up too.

thanks Tim

While I was doing all this I noticed the preset for calling the curves python plug-ins. I wonder if they have the same kind of plug-ins that call on gradients so they can be picked in a script.
0 x




User avatar
tim
Administrator
View: Showcase | Slideshow
Topic Posts: 7/15
Posts: 2071
Joined: 25 Sep 2016, 17:16
Cash on hand: 7,180.19 GLP
Bank: 42,250.25 GLP
Gender: Guy
Location: Victoria, BC
Website: https://gimplearn.net
Operating System: Windows
GIMP Version: 2.8.22
My Personal Blog
My FineArtAmerica
x 1106
x 240
Contact:
Canada

Post#13 by tim » 18 Feb 2017, 18:55


Not entirely what you mean by gradients can be picked in a script.
But there are many script that allow user to select a gradient(s).
0 x



aka Tin
Image gimplearn.net                                              

User avatar
Pegleg44

Forum Member
View: Showcase | Slideshow
Topic Posts: 8/15
Posts: 43
Joined: 28 Nov 2016, 19:12
Cash on hand: 258.13 GLP
x 11
Gimp Nation

Post#14 by Pegleg44 » 19 Feb 2017, 07:51


Yes, I guess you're right. I don't use them much for the kind of stuff I do.
0 x




Post Reply

Last 20 Members Who Visited This Topic

User avatar tim (1), User avatar Steve Reid (1), User avatar gnerd (1)

  • Similar Topics
    Replies
    Views
    Last post
• Featuring Members' Works (Image Attachments Only) •
1: tim
2: animicule
3: Ella
4: Ella
5: Issabella
6: Anonymous
7: Issabella

Who is online

Users browsing this forum: No registered users and 1 guest