Example #1
0
 def load_image(self):
     """Load the image from self.data, and set self.size
     """
     try:
         self._image_data
         return self.size
     except AttributeError:
         self._pil_image = Image.open(StringIO.BytesIO(self.data))
         self._pil_image = self._pil_image.convert('RGBA')
         w, h = self._pil_image.size
         if self._size:
             assert (w, h) == self._size
         else:
             self._size = w, h
         return w, h
Example #2
0
def plotdraw(): #name=None

    # img = StringIO.BytesIO()
    # sns.set_style("dark") #E.G.
    #
    # y = [1,2,3,4,5]
    # x = [0,2,1,3,4]
    #
    # plt.plot(x,y)
    # plt.savefig(img, format='png')
    # img.seek(0)
    #
    # plot_url = base64.b64encode(img.getvalue())
    # #return render_template('page.html', plot_url=plot_url)

    fig = create_figure()
    output = StringIO.BytesIO()
    FigureCanvas(fig).print_png(output)
    #plot_url = output #base64.b64encode(output.getvalue())
    #return render_template('page.html', plot_url=plot_url)
    return Response(output.getvalue(), mimetype='image/png')