Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 5:19 am

I did have a png file in my folder. It was a sample image that came with gradients I had downloaded. I put the new file in, but can't access the feature. Do you right click the gradients in the drop down menu for gradients? If so, that doesn't work for me. Thanks.

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 5:20 am

Never mind, I figured it out.

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 8:02 am

Thanks Tran. A very handy utility addition to GIMP! :)
Creates new gradients and edits those fine.

When i try and open one i did in the text editor it errors.

Image

Here is the code inside

Code:
<defs>
<linearGradient id="SVG myWhiteToBlueGrad">
<stop offset="0%" stop-color="#FFFFFF" />
<stop offset="100%" stop-color="#000ac3" />
</linearGradient>
</defs>


Do you think it has to do with the svg and rectangle tags? Because i noticed the new gradients contain that also.

Code:
<svg width="640" height="480" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="SVG TEST_RD">
<stop offset="0%" stop-color="#000000" stop-opacity="1.0" />
<stop offset="50%" stop-color="#ff0000" stop-opacity="1.0" />
<stop offset="100%" stop-color="#ffffff" stop-opacity="1.0" />
</linearGradient>
</defs>
<rect x="0" y="0" width="640" height="480" fill="url(#SVG TEST_RD)"/>
</svg>

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 8:05 am

Never mind i figured it out. My gradients have been saved as different names than what the code contains.

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 8:29 am

Also i had to change SF-SLIDER to SF-SPINNER i believe because i use the gimp-fu that creates columns instead of a scroll-bar it effected this function. It gets stuck on 100%. :lol

Image

Works beautifully now. :bigthup

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 9:34 am

I can't seem to edit them in GIMP, which is a pain in the butt. Is there an editor elsewhere or standalone?

Microsoft has a development gradient editor for Edge online, useful, but not what I was looking for:

https://developer.microsoft.com/en-us/m ... oundmaker/

If I make a copy of the gradient, then I can edit it. Weird, it would be nice if ANY gradient (CSS, SVG ,etc.) could be edited within GIMP.

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 10:13 am

mahvin wrote:I can't seem to edit them in GIMP, which is a pain in the butt. Is there an editor elsewhere or standalone?

Microsoft has a development gradient editor for Edge online, useful, but not what I was looking for:

https://developer.microsoft.com/en-us/m ... oundmaker/

If I make a copy of the gradient, then I can edit it. Weird, it would be nice if ANY gradient (CSS, SVG ,etc.) could be edited within GIMP.


Have you made sure you've named the gradient file the same as inside the code.

Oh you mean in GIMPs editor.

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 10:19 am

Yeah, it seems if the file isn't made natively within GIMP those features are null. Making a copy made it native so therefore GIMP lets you play with it. Developers got too many things on their plates for me to ask for yet another feature, so I'll just make do with copying for now.

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 10:57 am

dinasset wrote:thanks Tin
Just to inform you - because all my resources are maintaned in subfolder - I added in your filter for myself the subfolder name
SVG\\
after Gradients\\ in the explicit filenames
if you will consider in a next release to allow a subfolder, it would be great IMO

For the problem indicated by Rich maybe you may use the python function-expression
os.path.join() which can be used in conjunction with os.path.sep()


I am not sure what you mean... or how i would use those functions.
here's my code where it expands the user's home directory (at least for windows).
Code:
dirname = "~\\.gimp-2.8\\gradients\\"
   dirname = os.path.expanduser(dirname)

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 1:17 pm

@rich2005 or anyone else on Linux:
Can you try release 7 (in post #1) and let me know if the forward slashes change work in Linux.
I am on Windows and after this change it still works on Windows, so hopefully it solved the Linux problem.

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 1:29 pm

trandoductin wrote:
dinasset wrote:thanks Tin
Just to inform you - because all my resources are maintaned in subfolder - I added in your filter for myself the subfolder name
SVG\\
after Gradients\\ in the explicit filenames
if you will consider in a next release to allow a subfolder, it would be great IMO

For the problem indicated by Rich maybe you may use the python function-expression
os.path.join() which can be used in conjunction with os.path.sep()


I am not sure what you mean... or how i would use those functions.
here's my code where it expands the user's home directory (at least for windows).
Code:
dirname = "~\\.gimp-2.8\\gradients\\"
   dirname = os.path.expanduser(dirname)

example taken from one filter:
Code:
import os.path
...
...
newfile_fullname = os.path.join (dir_name, newfile_name + file_ext)

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 1:31 pm

using os.path.join you are not obliged to hardcode slashes which are different from one os to another

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 1:37 pm

trandoductin wrote:@rich2005 or anyone else on Linux:
Can you try release 7 (in post #1) and let me know if the forward slashes change work in Linux. ...


(Hardcoded or not ;)) All three functions working ok here on linux

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 1:46 pm

Now release 8.
Changed to not hardcoding slashes but use os.path.join() like Dinasset suggested.

Re: Creating svg gradients for Gimp (python script 3 functions).

Wed Sep 21, 2016 1:54 pm

@Dinasset
What about the subfolder thing you mentioned? do you mean where the functions are registered?... I already have all 3 functions under <Gradients>/SVG/

Re: Creating svg gradients for Gimp (python script 3 functions).

Thu Sep 22, 2016 12:26 am

I mean the sub-folder where to store the created gradients.
You had (old version) : filename = "~\\.gimp-2.8\\gradients\\" + gradient_name + ".svg"
I changed it for myself to : filename = "~\\.gimp-2.8\\gradients\\SVG\\" + gradient_name + ".svg"
but having the subfolder name as a parameter in the panel could be more flexible

Re: Creating svg gradients for Gimp (python script 3 functions).

Thu Sep 22, 2016 12:46 am

:( ah too late now, users might have already created some files inside main gradients folder.
i don't want to deal with handling subfolder SVG and main gradients folder.

Re: Creating svg gradients for Gimp (python script 3 functions).

Thu Sep 22, 2016 1:01 am

As you like Tin, but in any case if you add the subfolder parameter you'll not have to deal both with the subfolder and the main, only with the entered subfolder (user can move the already created there, if preferred).
No problem for me, I stick on my "patched" version.
Thanks again.

Re: Creating svg gradients for Gimp (python script 3 functions).

Thu Sep 22, 2016 6:46 am

Why can't you add the subfolder option as a user defined destination? EXPORT AS Then just have GIMP refresh gradients? Not sure if i need version 8 Tran. Mine works fine now that i use the same names in the code and as the file name itself. :) Fine addition to GIMP. Thank you.

Re: Creating svg gradients for Gimp (python script 3 functions).

Tue Nov 01, 2016 4:32 pm

Tin - do I have a script problem or is it just a 'seniors moment' of total confusion. :oops:

A few weeks back I created a number of SVG gradients using your script, and was able to add and delete stops. Now I want to amend one but when I right click on the gradient and select the add/delete stops options, the forms that display seem to have 'deformed sliders', like these examples -

Image

Image

I can create a new SVG gradient, but again if I try to add/delete stops, the same forms as above are displayed and they do not look like your original examples above.

I have dowmloaded/installed the script again but nothing changes.
Post a reply