below python function convert emf
format image to png
.
from wand.image import Image
def process_image(self, image):
if image.content_type == "image/x-emf":
with image.open() as image_bytes:
with Image(blob=image_bytes.read(), format="emf") as img:
img = img.convert("png")
encoded_src = base64.b64encode(
img.make_blob()).decode("ascii")
return {"src": "data:{0};base64,{1}".format("PNG", encoded_src)}
it use wand library as you can see. wand itself use ImageMagic internally.
this code works perfectly fine in Windows but in Linux raise below exception:
MissingDelegateError at /doc/s/19/1/0/010212/
no decode delegate for this image format `EMF' @ error/blob.c/BlobToImage/363
in below this stackoverflow link it says EMF
is Windows supported and not supported by Linux.
I got to fix it on Linux, is there any solution for it? its hard to believe that ImageMagic and Wand doesn’t support Linux btw.
also wand and magic versions:
# pip freeze | grep -i wand
Wand==0.6.11
# apt list --installed | grep -i magic
imagemagick-6-common/oldstable,oldstable-security,now 8:6.9.11.60+dfsg-1.3+deb11u1 all [installed,automatic]
libmagic-mgc/oldstable,oldstable-security,now 1:5.39-3+deb11u1 amd64 [installed,automatic]
libmagic1/oldstable,oldstable-security,now 1:5.39-3+deb11u1 amd64 [installed,automatic]
libmagickcore-6-arch-config/oldstable,oldstable-security,now 8:6.9.11.60+dfsg-1.3+deb11u1 amd64 [installed,automatic]
libmagickcore-6-headers/oldstable,oldstable-security,now 8:6.9.11.60+dfsg-1.3+deb11u1 all [installed,automatic]
libmagickcore-6.q16-6-extra/oldstable,oldstable-security,now 8:6.9.11.60+dfsg-1.3+deb11u1 amd64 [installed,automatic]
libmagickcore-6.q16-6/oldstable,oldstable-security,now 8:6.9.11.60+dfsg-1.3+deb11u1 amd64 [installed,automatic]
libmagickcore-6.q16-dev/oldstable,oldstable-security,now 8:6.9.11.60+dfsg-1.3+deb11u1 amd64 [installed,automatic]
libmagickwand-6-headers/oldstable,oldstable-security,now 8:6.9.11.60+dfsg-1.3+deb11u1 all [installed,automatic]
libmagickwand-6.q16-6/oldstable,oldstable-security,now 8:6.9.11.60+dfsg-1.3+deb11u1 amd64 [installed,automatic]
libmagickwand-6.q16-dev/oldstable,oldstable-security,now 8:6.9.11.60+dfsg-1.3+deb11u1 amd64 [installed,automatic]
libmagickwand-dev/oldstable,oldstable-security,now 8:6.9.11.60+dfsg-1.3+deb11u1 all [installed]