source: trunk/exports/G2export_image.py @ 1115

Last change on this file since 1115 was 1115, checked in by toby, 9 years ago

rework exports for new types

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 1.6 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3########### SVN repository information ###################
4# $Date: 2013-10-18 21:00:32 +0000 (Fri, 18 Oct 2013) $
5# $Author: toby $
6# $Revision: 1115 $
7# $URL: trunk/exports/G2export_image.py $
8# $Id: G2export_image.py 1115 2013-10-18 21:00:32Z toby $
9########### SVN repository information ###################
10'''Code to demonstrate how export routines are created.
11This loads in an image and saves it in PNG format
12'''
13import os.path
14import scipy.misc
15import GSASIIpath
16GSASIIpath.SetVersionNumber("$Revision: 1115 $")
17import GSASIIIO as G2IO
18import GSASIImath as G2mth
19
20class ExportImagePNG(G2IO.ExportBaseclass):
21    '''Used to create a PNG file for a GSAS-II image
22
23    :param wx.Frame G2frame: reference to main GSAS-II frame
24    '''
25    def __init__(self,G2frame):
26        super(self.__class__,self).__init__( # fancy way to say <parentclass>.__init__
27            G2frame=G2frame,
28            formatName = 'PNG',
29            extension='.png',
30            longFormatName = 'Export image in PNG format'
31            )
32        self.exporttype = ['image']
33        #self.multiple = True
34    def Exporter(self,event=None):
35        '''Export an image
36        '''
37        # the export process starts here
38        self.InitExport(event)
39        # load all of the tree into a set of dicts
40        self.loadTree()
41        if self.ExportSelect(False): return
42        # process the selected image(s) (at present only one image)
43        for i in sorted(self.histnam): 
44            imgFile = self.Histograms[i].get('Data',(None,None))
45            Comments,Data,Npix,Image = G2IO.GetImageData(self.G2frame,imgFile)
46            scipy.misc.imsave(self.filename,Image)
47            print('Image '+str(imgFile)+' written to file '+str(self.filename))                   
Note: See TracBrowser for help on using the repository browser.