I am using wand and pytesseract to get the text of pdfs uploaded to a django website like so:
image_pdf = Image(blob=read_pdf_file, resolution=300)
image_png
The code from @emcconville works, and my temp folder is not filling up with magick-* files anymore
I needed to Import ctypes and not cstyles
I also got the error mentioned by @kerthik
solved it by saving the image and loading it again, it is properly also possible to save it to memory
from PIL import Image as PILImage
...
context.save(filename="temp.jpg")
text = pytesseract.image_to_string(PILImage.open("temp.jpg"))`
EDIT I found the in memory conversion on How to convert wand.image.Image to PIL.Image?
img_buffer = np.asarray(bytearray(context.make_blob(format='png')),dtype='uint8')
bytesio = io.BytesIO(img_buffer)
text = ytesseract.image_to_string(PILImage.open(bytesio),lang="dan")