Re: Testing out the theme

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here's a few hackish scripts that i use from time to time to get the
filesize down

Svg round.pl  rounds node coords to a set decimal places and outputs
to the terminal  ( i just copy paste the output into gedit then find
replace any two spaces with \t (tab)

also for the more gui people out there...there is reduce precision!!!!

The two setprecision files need to be in your
/usr~/share/inkscape/extensions folder.
They will add a new menu item in the effects > modify paths menu (
only setting to two decimal places works at this point ).

ANOTHER RAD HACK !!!!
Opening the svg file and looking for the chunks of text that start
inside <![CDATA[      and end with  ]]>  will remove the encoded
images  ( get your local commandline scripting ninja to write up a
forloop the does this for you to all files ).

um..  sorry ive been rambling ( got a little flu ) ..  but i  hope all
this helps




On 8/16/06, Máirín Duffy <duffy@xxxxxxxxxx> wrote:
Diana Fong wrote:
> Leon wrote:
>> I see. Does Illustrator supports exporting to plain svg? It's more
>> portable.
>>
>>
> Illustrator saves as SVG and compressed SVGz...I usually save as the
> regular svg with the default options checked.  I just tried saving with
> various combinations of things unchecked and it doesn't seem to help.
> It did however, save as a much smaller file.  I think I'll just have to
> go in and edit each later in Inkscape.

I wonder if a script exists to parse through the broken Illustrator SVG
and take out all the extra crud?

Nicu, what process do you follow to clean it up? What nodes have to be
deleted?

~m

_______________________________________________
Fedora-art-list mailing list
Fedora-art-list@xxxxxxxxxx
http://www.redhat.com/mailman/listinfo/fedora-art-list

Attachment: svg-round2.pl
Description: Perl program

Attachment: setprecision.inx
Description: Binary data

#!/usr/bin/env python
"""


Copyright (C) 2006 Wade Mealing <wmealing@xxxxxxxxxx>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
"""



import getopt
import sys , optparse
from xml.dom import minidom

import re 
from inkex import InkOption



__author__ = "Wade Mealing <wmealing@xxxxxxxxxx>"
__version__ = "$Revision: 0.02 $"
__date__ = "$Date: Wed Jul 26 11:01:20 2006 $"
__copyright__ = "Copyright (c) 2006 Wade Mealing"
__license__ = "Python"


class InkscapeDoc:

	sourcefile = ""
	precision = 2  

	my_regex = r'[0-9]+\.[0-9]+'
	p = re.compile( my_regex )

	elements_to_round = [ 	'x', 'y',  'x1' , 'y1', 'x2', 'y2',  'width', 'height' , 'd' , 
				'sodipodi:ry', 'sodipodi:rx', 'sodipodi:cy', 'sodipody:cx' ,
				'cx', 'cy', 'fx', 'fy', 'r'  ]

	def __init__(self, sourcefile, precision):
		self.sourcefile = sourcefile
		self.precision = precision
		self.xmldoc = minidom.parse( self.sourcefile )
		stream = open( sourcefile)
		stream.close() 
		self.parse( self.xmldoc) 

	def getxml(self):
		return self.xmldoc.toxml()

	def roundnum(self,  match ):
		return str ( round( float (match.group()), self.precision) )

	def parse_Document(self, node):
                for c in node.childNodes:
                        self.parse( c )

	def parse_Element(self, node):

		# get a list of the attributes for this element
		keys = node.attributes.keys()

		for at in keys:
			if unicode(at) in self.elements_to_round:
				x = self.p.sub(self.roundnum,  node.attributes[at].value)
				node.attributes[at].value = x
	
	def parse_Text(self, node):
		pass

	def parse_Comment(self,node):
		pass

	def parse( self, node):
		parseMethod = getattr(self , "parse_%s" % node.__class__.__name__)
		parseMethod(node)

		for c in node.childNodes:
			self.parse( c ) 


class SetPrecision:
        def __init__(self):
        	self.document=None
        	self.selected={}
        	self.options=None
        	self.args=None
        	self.OptionParser = optparse.OptionParser(usage="usage: %prog [options] SVGfile",option_class=InkOption)
        
		self.OptionParser.add_option("--id",
                        action="append", type="string", dest="ids", default=[],
                        help="id attribute of object to manipulate")

                self.OptionParser.add_option("-p", "--precision",
                                         action="store", type="int",
                                         dest="precision", default=2,
                                         help="The number of decimal places you wish to have numbers rounded to")

	def getoptions(self,args=sys.argv[1:]):
        	"""Collect command line arguments"""
        	self.options, self.args = self.OptionParser.parse_args(args)

        def execute(self):
		# I essentially just skipped all the inkex magic, I know.
		# pdb.set_trace() 
		self.getoptions()
                k = InkscapeDoc( self.args[0], self.options.precision )
		print k.getxml() 

e = SetPrecision()
e.execute()
_______________________________________________
Fedora-art-list mailing list
Fedora-art-list@xxxxxxxxxx
http://www.redhat.com/mailman/listinfo/fedora-art-list

[Index of Archives]     [Fedora Music]     [Fedora Development]     [Linux Kernel]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Directory]     [PAM]     [Big List of Linux Books]     [Gimp]     [Yosemite News]

  Powered by Linux