source: trunk/exports/G2export_image.py

Last change on this file was 5576, checked in by toby, 2 years ago

rework docs for exports

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