It is currently Fri Apr 19, 2024 1:01 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: Re: Path Save and Load Script for GIMP
PostPosted: Thu Oct 13, 2016 12:38 pm  (#11) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
ofnuts wrote:
Could be done by looking at the SVG file with the xml.eTree library... but why would you need the size of the original image?

Because that's how i can have load methods like RELATIVE (percentage), RELATIVE WIDTH KEEPING ASPECT RATIO and RELATIVE HEIGHT KEEPING ASPECT RATIO. I need the original image's dimensions in order to know how the path sits on the original image in order to apply the same percentage on to the current image (that it's being loaded on).

_________________
TinT


Top
 Post subject: Re: Path Save and Load Script for GIMP
PostPosted: Fri Oct 14, 2016 3:42 pm  (#12) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4736
Quite simple actually:
import  xml.etree.ElementTree as ET
import sys

if len(sys.argv) < 2:
    print("Usage: %s {svgfile}" % sys.argv[0])
    exit(2)

svgFile=sys.argv[1]
svg=ET.parse(svgFile).getroot()
print '%7.2f %7.2f %s' % (float(svg.attrib['width']),float(svg.attrib['height']),svgFile)


As far as I can tell, xml.etree.ElementTree is part of the Python package distributed with the Windows Gimp version.

In some files, you'll find heigh/width specified as '150px' or '2.4in' or '1200pt' so you may have to be a bit cautious when converting the values. Some files also define a 'viewBox' attribute.

_________________
Image


Top
 Post subject: Re: Path Save and Load Script for GIMP
PostPosted: Fri Oct 14, 2016 3:48 pm  (#13) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
I did it using the viewBox attribute because i only want to deal with exported path by GIMP. :hehe

_________________
TinT


Top
 Post subject: Re: Path Save and Load Script for GIMP
PostPosted: Sat Oct 15, 2016 3:13 am  (#14) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Trandoductin instead of using the image size could you make use of the bounding box of the current selection if one exists.

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: Path Save and Load Script for GIMP
PostPosted: Sat Oct 15, 2016 6:22 am  (#15) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4045
Graechan wrote:
Trandoductin instead of using the image size could you make use of the bounding box of the current selection if one exists.


I like the way you think...

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Path Save and Load Script for GIMP
PostPosted: Sat Oct 15, 2016 2:26 pm  (#16) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
Shhh Graechan.. :hehe
I'll update it soon

_________________
TinT


Top
 Post subject: Re: Path Save and Load Script for GIMP
PostPosted: Sat Oct 15, 2016 4:34 pm  (#17) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
Okay just updated the download link to point to version 3 of script.
Which works on selection bounding box.
It's easy because this script i am calculating the path myself.

But I tried to also apply this to the Import SVG Path with load methods and it's tripping me out i kept getting weird bugs.... i don't know about that one..maybe save it for another day when i am not so tripped out by simple scaling math.

_________________
TinT


Top
Post new topic Reply to topic  [ 17 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts script to load text file and create text layer

6

No new posts Attachment(s) Shortening mouse/keystrokes save/export script or method to implement?

41

No new posts Where did GIMP save my file, & how do I change default save location

5

No new posts Attachment(s) i struggle with the option to copy the path - the path where a file i

3

No new posts Cant load GMIC plugin in gimp

2



* Login  



Powered by phpBB3 © phpBB Group