<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Gimp on Andrew's Memory Blog</title><link>https://andrewmemory.acornwall.net/tags/gimp/</link><description>Recent content in Gimp on Andrew's Memory Blog</description><generator>Hugo -- gohugo.io</generator><image><url>https://andrewmemory.acornwall.net/img/rss_image.png</url><title>Gimp on Andrew's Memory Blog</title><link>https://andrewmemory.acornwall.net/</link></image><language>en</language><managingEditor>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</managingEditor><webMaster>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</webMaster><copyright>Copyright 2009--2025</copyright><lastBuildDate>Thu, 01 Sep 2016 22:03:20 -0700</lastBuildDate><atom:link href="https://andrewmemory.acornwall.net/tags/gimp/index.xml" rel="self" type="application/rss+xml"/><item><title>Making use of GIMP plugins</title><link>https://andrewmemory.acornwall.net/blog/2016-09-01-making-use-of-gimp-plugins/</link><pubDate>Thu, 01 Sep 2016 22:03:20 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2016-09-01-making-use-of-gimp-plugins/</guid><description>
&lt;h2 class="relative group"&gt;(or how to draw an arrow with an outline)
&lt;div id="or-how-to-draw-an-arrow-with-an-outline" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#or-how-to-draw-an-arrow-with-an-outline" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;As part of a project that I&amp;rsquo;m working on, I found myself drawing lots of red arrows with yellow outlines. To do this I was using the GIMP image editor.&lt;/p&gt;
&lt;p&gt;This was tedious. I would draw a yellow arrow for the outline, then draw a red arrow slightly smaller, then merge down so I had one layer. I started wondering about scripting it.&lt;/p&gt;
&lt;p&gt;First I started by just calling the FU_arrow.scm script with my values. It wasn&amp;rsquo;t hard to write a script that did that. In my case, I did:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;    (FU-arrow image drawable
            80.0
            25
            TRUE
            75
            500 ; brush thickness
            FALSE ; use forst point as head
            FALSE ; delete path after arrow was drawn
            TRUE ; use new layer for arrow
            FALSE ; draw double headed arrow
            FALSE ; useless
            )&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;In other words, my plugin just called the FU-arrow plugin. Next I added a little bit of code around that:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;    (gimp-image-undo-group-start image)
    (gimp-context-push)
(gimp-palette-set-foreground &amp;#39;(255 255 0)) ; yellow
(FU_arrow image drawable 80.0 ...) ; draw outer (bottom) layer
(gimp-palette-set-foreground &amp;#39;(255 0 0)) ; red
(FU_arrow image drawable 80.0 ...) ; draw inner (top) layer
(gimp-context-pop)
(gimp-image-undo-group-end image)&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;This saved the state and set the foreground colours appropriately so I didn&amp;rsquo;t have to, and also made it easy to undo in a single action.&lt;/p&gt;
&lt;p&gt;You can see that I called FU_arrow twice. Next I needed to merge them down. For that, I used the facility in the arrow plugin that lets you create the arrow as a new layer. New layers are added at the top of the layer stack, so it&amp;rsquo;s fairly easy to grab that and work with it. The interesting code is:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;    (set! current-layers (cadr (gimp-image-get-layers image)))
    (set! arrow-foreground-layer
      (vector-ref current-layers 0))&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Once I have a handle on the foreground layer, I can use gimp-image-merge-down with CLIP-TO-BOTTOM-LAYER to merge the two layers:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;(gimp-image-merge-down image arrow-foreground-layer CLIP-TO-BOTTOM-LAYER)&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Because I know nobody else created a layer between the two layers I created, it&amp;rsquo;s easy to get a handle on the new layers the FU-arrow plugin made.&lt;/p&gt;
&lt;p&gt;On Gimp 2.10, I noticed that the thickness of my arrow was tracking the thickness of the currently-selected paintbrush. To fix that, I chose the brush width explicitly using:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;(gimp-context-set-brush-size 30)
(gimp-context-set-brush-hardness 1.00)&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;for the outer brush, and 20 for the inner brush.&lt;/p&gt;
&lt;p&gt;My total plugin is:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;(define
(script-fu-quick-arrow image drawable)
(let *
(
(arrow-background-layer -1)
(arrow-foreground-layer -1)
(current-layers -1)
)
(gimp-image-undo-group-start image)
(gimp-context-push)
(gimp-context-set-brush-size 30)
(gimp-context-set-brush-hardness 1.00)
(gimp-palette-set-foreground &amp;#39;(255 255 0))
(FU-arrow image drawable
80.0
25
TRUE
75
500 ; brush thickness
FALSE ; use forst point as head
FALSE ; delete path after arrow was drawn
TRUE ; use new layer for arrow
FALSE ; draw double headed arrow
FALSE ; useless
)
(set! current-layers (cadr (gimp-image-get-layers image)))
(set! arrow-background-layer
(vector-ref current-layers 0))
(gimp-context-set-brush-size 20)
(gimp-palette-set-foreground &amp;#39;(255 0 0))
(FU-arrow image drawable
80.0
25
TRUE
75
1 ; brush thickness
FALSE ; use first path as head
TRUE ; delete path after arrow was drawn
TRUE ; use new layer for arrow
FALSE ; draw double headed arrow
FALSE ; useless
) ;script-fu-draw-arrow function call
(set! current-layers (cadr (gimp-image-get-layers image)))
(set! arrow-foreground-layer
(vector-ref current-layers 0))
(if (= -1 arrow-foreground-layer) (gimp-message &amp;#34;Foreground is -1&amp;#34;))
(if (= -1 arrow-background-layer) (gimp-message &amp;#34;Background is -1&amp;#34;))
(gimp-image-merge-down image arrow-foreground-layer
CLIP-TO-BOTTOM-LAYER )
(gimp-context-pop)
(gimp-image-undo-group-end image)
) ; let
) ;define
; Register with GIMP:
(script-fu-register &amp;#34;script-fu-quick-arrow&amp;#34;
_&amp;#34;Quick Arrow&amp;#34;
_&amp;#34;Draw a nearly arbitrary arrow in your image in red with a yellow outline. Arrow will be created in a separate layer. Needs FU_arrow.scm&amp;#34;
&amp;#34;Andrew&amp;#34;
&amp;#34;2016, Andrew&amp;#34;
&amp;#34;2016-09-01&amp;#34;
&amp;#34;*&amp;#34;
SF-IMAGE &amp;#34;The image&amp;#34; 0
SF-DRAWABLE &amp;#34;The drawable&amp;#34; 0
)
(script-fu-menu-register &amp;#34;script-fu-quick-arrow&amp;#34; &amp;#34;/Script-Fu/&amp;#34;)&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Quick edit: to install the script, copy it to the scripts directory. You can find that with Edit -&amp;gt; Preferences -&amp;gt; Folders -&amp;gt; Scripts (I used the user folder rather than the system folder). Then Filters -&amp;gt; Script-Fu -&amp;gt; Refresh Scripts. Et voilà!&lt;/p&gt;</description></item></channel></rss>