EPS support for images
svn: r756
This commit is contained in:
		| @@ -159,22 +159,25 @@ class GrampsParser: | ||||
|             self.count = self.count + 1 | ||||
|  | ||||
|     def start_location(self,attrs): | ||||
|         """Bypass the function calls for this one, since it appears to | ||||
|         take up quite a bit of time""" | ||||
|          | ||||
|         loc = Location() | ||||
|         if attrs.has_key('city'): | ||||
|             loc.set_city(u2l(attrs['city'])) | ||||
|             loc.city = u2l(attrs['city']) | ||||
|         if attrs.has_key('parish'): | ||||
|             loc.set_parish(u2l(attrs['parish'])) | ||||
|             loc.parish = u2l(attrs['parish']) | ||||
|         if attrs.has_key('state'): | ||||
|             loc.set_state(u2l(attrs['state'])) | ||||
|             loc.state = u2l(attrs['state']) | ||||
|         if attrs.has_key('county'): | ||||
|             loc.set_county(u2l(attrs['county'])) | ||||
|             loc.county = u2l(attrs['county']) | ||||
|         if attrs.has_key('country'): | ||||
|             loc.set_country(u2l(attrs['country'])) | ||||
|             loc.country = u2l(attrs['country']) | ||||
|         if self.locations > 0: | ||||
|             self.placeobj.add_alternate_locations(loc) | ||||
|         else: | ||||
|             self.placeobj.set_main_location(loc) | ||||
|         self.locations = self.locations + 1 | ||||
|             self.locations = self.locations + 1 | ||||
|          | ||||
|     def start_coord(self,attrs): | ||||
|         if attrs.has_key('lat'): | ||||
|   | ||||
| @@ -86,11 +86,56 @@ class ImgManip: | ||||
|             return buf | ||||
|         else: | ||||
|             im = PIL.Image.open(self.source) | ||||
|             if im.mode != 'RGB': | ||||
|                 im.draft('RGB',im.size) | ||||
|                 im = im.convert("RGB") | ||||
|             return im.tostring("jpeg","RGB") | ||||
|  | ||||
|     def eps_data(self): | ||||
|         if no_pil: | ||||
|             cmd = "%s '%s' 'eps:-'" % (const.convert,self.source) | ||||
|             r,w = popen2.popen2(cmd) | ||||
|             buf = r.read() | ||||
|             r.close() | ||||
|             w.close() | ||||
|             return buf | ||||
|         else: | ||||
|             import StringIO | ||||
|  | ||||
|             g = StringIO.StringIO() | ||||
|             im = PIL.Image.open(self.source) | ||||
|             im.save(g,"eps") | ||||
|             g.seek(0) | ||||
|             buf = g.read() | ||||
|             g.close() | ||||
|             return buf | ||||
|  | ||||
|     def eps_scale_data(self,x,y): | ||||
|         if no_pil: | ||||
|             cmd = "%s -geometry %dx%d '%s' 'eps:-'" % (const.convert,x,y,self.source) | ||||
|             r,w = popen2.popen2(cmd) | ||||
|             buf = r.read() | ||||
|             r.close() | ||||
|             w.close() | ||||
|             return buf | ||||
|         else: | ||||
|             import StringIO | ||||
|  | ||||
|             g = StringIO.StringIO() | ||||
|             im = PIL.Image.open(self.source) | ||||
|             im.thumbnail((width,height)) | ||||
|             if im.mode != 'RGB': | ||||
|                 im.draft('RGB',im.size) | ||||
|                 im = im.convert("RGB") | ||||
|             im.save(g,"eps") | ||||
|             g.seek(0) | ||||
|             buf = g.read() | ||||
|             g.close() | ||||
|             return buf | ||||
|  | ||||
|     def png_scale_data(self,x,y): | ||||
|         if no_pil: | ||||
|             cmd = "%s -geometry %dx%d'%s' 'jpg:-'" % (const.convert,x,y,self.source) | ||||
|             cmd = "%s -geometry %dx%d '%s' 'jpg:-'" % (const.convert,x,y,self.source) | ||||
|             r,w = popen2.popen2(cmd) | ||||
|             buf = r.read() | ||||
|             r.close() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user