0

Is there a way I can convert the Image() object to blob?

If I want to serve an image which is created by pgmagick to a HTTP request without writing it on the disk, I see converting the image object to blob and then streaming back to the request is the only option.

Let me know if there are any alternatives to achieve this.

Below is the code sample which creates an image.

from flask import Flask
from pgmagick import Image, Geometry, Color, \
                     DrawableText
app = Flask(__name__)

@app.route("/")
def hello():
  image = Image(Geometry(300,300), Color("yellow"))
  image.fontPointsize(30)
  text = DrawableText(30,200, "hello stackoverflow")
  image.draw(text)
  #return image.Blob() # is there any similar functions?

if __name__ == "__main__":
  app.run()

I am looking for a wrapper on this: http://www.graphicsmagick.org/api/blob.html#imagetoblob

vikas kv
  • 386
  • 2
  • 15
  • 1
    I honestly have no intention of being inflammatory, nor disparaging and have no axe to grind nor affiliations with any developers or companies, but in 6 years following image processing questions on Stack Overflow I have never come across `pgmagick`. It may be a wonderful package although there doesn't appear to be much recent development. I just want to mention before you become too reliant on it, that most folk seem to be using OpenCV, Wand, PIL/Pillow, scikit-image or pyvips. YMMV. – Mark Setchell Sep 05 '19 at 11:57
  • @MarkSetchell Thanks. This information is really helpful for me. We are currently using graphics magick with perl interface, and we want to move out of perl. Right now we are kind of in research stage to find the suitable replacement, and was looking for alternatives in Python. – vikas kv Sep 05 '19 at 13:27

0 Answers0