diff options
| author | Jos Hirth <github@kaioa.com> | 2007-01-08 05:29:09 +0000 |
|---|---|---|
| committer | amphi <amphi@users.sourceforge.net> | 2007-01-08 05:29:09 +0000 |
| commit | 4597966a80c0ffb5f07615f2701342552fbfd0ae (patch) | |
| tree | 0f66b3a8268f3cdf767bb22032a5705f6b77c6d9 | |
| parent | the new gtk28 requirement ensures cairo so we no longer need to link it static (diff) | |
| download | inkscape-4597966a80c0ffb5f07615f2701342552fbfd0ae.tar.gz inkscape-4597966a80c0ffb5f07615f2701342552fbfd0ae.zip | |
automatic file extension
(bzr r2155)
| -rw-r--r-- | share/extensions/extractimage.inx | 1 | ||||
| -rw-r--r-- | share/extensions/extractimage.py | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/share/extensions/extractimage.inx b/share/extensions/extractimage.inx index 1c80ccaae..4036c05db 100644 --- a/share/extensions/extractimage.inx +++ b/share/extensions/extractimage.inx @@ -4,6 +4,7 @@ <dependency type="executable" location="extensions">extractimage.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <param name="filepath" type="string" _gui-text="Path to save image">none</param> + <param name="desc" type="description">Note: The file extension is appended automatically.</param> <effect> <object-type>all</object-type> <effects-menu> diff --git a/share/extensions/extractimage.py b/share/extensions/extractimage.py index f1b0f6f7a..5807c9e5b 100644 --- a/share/extensions/extractimage.py +++ b/share/extensions/extractimage.py @@ -22,11 +22,20 @@ import inkex, base64 class MyEffect(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) + self.OptionParser.add_option("--desc") self.OptionParser.add_option("--filepath", action="store", type="string", dest="filepath", default=None, help="") def effect(self): + mimesubext={ + 'png' :'.png', + 'bmp' :'.bmp', + 'jpeg':'.jpg', + 'jpg' :'.jpg', #bogus mime + 'icon':'.ico', + 'gif' :'.gif' + } ctx = inkex.xml.xpath.Context.Context(self.document,processorNss=inkex.NSS) # exbed the first embedded image @@ -39,6 +48,16 @@ class MyEffect(inkex.Effect): if (xlink.value[:4]=='data'): comma = xlink.value.find(',') if comma>0: + #get extension + fileext='' + semicolon = xlink.value.find(';') + if semicolon>0: + for sub in mimesubext.keys(): + if sub in xlink.value[5:semicolon]: + fileext=mimesubext[sub] + path=path+fileext; + break + #save data = base64.decodestring(xlink.value[comma:]) open(path,'wb').write(data) xlink.value = path |
