- Timestamp:
- Jul 29, 2015 9:25:28 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/uq/examples/zoo/image/image.py
r5778 r5780 16 16 from Rappture.encoding import decode, encode 17 17 18 18 19 # uncomment these for debugging 19 20 # sys.stdout = open('image.out', 'w') 20 21 # sys.stderr = open('image.err', 'w') 22 23 24 # rotate image data 25 def rotate_image(data, angle): 26 27 # bug workaround in some PIL versions 28 def fileno(): 29 raise AttributeError 30 31 # open image from data and rotate 32 image = Image.open(BytesIO(data)) 33 rot = image.rotate(angle, expand=True) 34 # save image to a file in memory 35 memfile = BytesIO() 36 memfile.fileno = fileno # required in some broken PILs 37 rot.save(memfile, image.format) 38 return memfile.getvalue() 39 21 40 22 41 # open the XML file containing the run parameters … … 30 49 angle = float(Rappture.Units.convert(angle, to='deg', units='off')) 31 50 51 rx['output.image(outi).about.label'] = "Rotated Image" 32 52 33 rx['output.image(outi).about.label'] = "Rotated Image" 34 image = Image.open(BytesIO(data)) 35 image = image.rotate(angle, expand=True) 36 37 # save image to a file in memory 38 memfile = BytesIO() 39 image.save(memfile, 'GIF') 40 data = memfile.getvalue() 53 data = rotate_image(data, angle) 41 54 42 55 # Image data must be B64 or ZB64 encoded.
Note: See TracChangeset
for help on using the changeset viewer.