[Clipart] [Fwd: Tech Icons]

tom whiteley tom.whiteley at gmail.com
Thu Apr 12 04:07:39 PDT 2007


Python script ok?

Usage:
python sygbinstrip.py inputfile > outputfile

It just removes all <image> type tags from a file and print the result
to stdout.

I'm not that familar with the internals of svg so hope this is the
right way to do it.

There is a slight flaw that it removes all newlines as there seems to
be a bug in multi-line regex matching my version of python, but the
output is still valid svg.

Tom.


On 4/11/07, Jon Phillips <jon at rejon.org> wrote:
> On Wed, 2007-04-11 at 08:15 +1000, Ryan wrote:
> > This image was deleted because it contains imbedded bitmaps. I think this
> > may be just adobe illustrator saving this as embedded bitmaps before saving
> > to svg. JohnnyAutomatic or any other illustrator users please give your
> > opinions - (I use inkscape, so im not much help)
> >
> > In firefox, the imbedded bitmaps are displayed properly, however, in opera,
> > they do not. We do not currently accept images with imbedded bitmaps in
> > them, as they are not scalable. That is why the image was deleted. I have
> > unbanned the one you reuploaded for the time being - the url is :
> > http://openclipart.org/media/files/iedesign/3321
>
> Illustrator does something nasty with SVG files by making a bitmap
> thumbnail of the image embedded in the SVG, thus producing a monstrous
> file. This can be fixed by opening in Inkscape and pruning out this by
> hand atm unfortunately.
>
> Does anyone have a script to prune out this stuff and/or want to make
> one? That would be a cool task...
>
> Jon
>
> > Cheers,
> >
> > ryanlerch
> >
> > > -----Original Message-----
> > > From: clipart-bounces at lists.freedesktop.org [mailto:clipart-
> > > bounces at lists.freedesktop.org] On Behalf Of Jon Phillips
> > > Sent: Wednesday, 11 April 2007 6:29 AM
> > > To: Open Clip Art Library list
> > > Subject: [Clipart] [Fwd: Tech Icons]
> > >
> > > -------- Forwarded Message --------
> > > > From: ie Design <l_mc_2000 at yahoo.com>
> > > > To: clipart-owner at lists.freedesktop.org
> > > > Subject: Tech Icons
> > > > Date: Tue, 10 Apr 2007 13:16:48 -0700 (PDT)
> > > >
> > > > My last upload has recently been deleted because of a formatting
> > > > issue. I reloaded it and have a couple of ratings so it seems it no
> > > > longer is a format issue. Now it is being moderated. May I ask why?
> > > >
> > > > iedesign
> > > > Image-Tech Icons
> > >
> > > Hi ie Design, I'm fwd'ing to our list for further discussion...
> > >
> > > More than likely your upload is of a trademarked image or something that
> > > is copyrighted and/or only a bitmap file and not an SVG.
> > >
> > > Jon
> > >
> > > >
> > > > ______________________________________________________________________
> > > > Be a PS3 game guru.
> > > > Get your game face on with the latest PS3 news and previews at Yahoo!
> > > > Games.
> > > --
> > > Jon Phillips
> > >
> > > San Francisco, CA
> > > USA PH 510.499.0894
> > > jon at rejon.org
> > > http://www.rejon.org
> > >
> > > MSN, AIM, Yahoo Chat: kidproto
> > > Jabber Chat: rejon at gristle.org
> > > IRC: rejon at irc.freenode.net
> > >
> > > _______________________________________________
> > > clipart mailing list
> > > clipart at lists.freedesktop.org
> > > http://lists.freedesktop.org/mailman/listinfo/clipart
> >
> --
> Jon Phillips
>
> San Francisco, CA
> USA PH 510.499.0894
> jon at rejon.org
> http://www.rejon.org
>
> MSN, AIM, Yahoo Chat: kidproto
> Jabber Chat: rejon at gristle.org
> IRC: rejon at irc.freenode.net
>
> _______________________________________________
> clipart mailing list
> clipart at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/clipart
>
-------------- next part --------------
#!/usr/bin/python

import re
import sys

#match any opening image tag
image_tag_re_str = r'\<image .*?\>'
image_open_re = re.compile( image_tag_re_str, re.IGNORECASE | re.DOTALL  )

#match any closing image tag, case insensitive
image_close_re = re.compile( r'\<\/image\>', re.IGNORECASE )

def Strip( text ):
  "Strip text of any image tag's"
  #strip opening image tags
  text = image_open_re.sub( "", text )
  #strip any closing
  text = image_close_re.sub( "", text )
  return text
  
def StripFile( svgfile ):
  "Load file and strip image refs, return resulting text"
  contents = open( svgfile, 'r' ).read()
  #flatten
  contents = contents.replace( "\r", "" )
  contents = contents.replace( "\n", "" )
  return Strip( contents )
  
if __name__ == "__main__":
  if len( sys.argv ) != 2:
    print "Expected svg filename to operate on"
    sys.exit( -1 )
  else:
    file = sys.argv[ 1 ]
    output = StripFile( file )
    print output

  
  


More information about the clipart mailing list