[[ImageMagick]] | [[Python]] - https://docs.wand-py.org/ // - https://app.assembla.com/wiki/show/pythonmagickwand -- https://buildmedia.readthedocs.org/media/pdf/wand/latest/wand.pdf > pip install wand * I/O [#tba8a4ce] - Reading blob object in Python using wand library -- https://www.codespeedy.com/reading-blob-object-in-python-using-wand-library/ with open("random_image.png", "rb") as f: image_blob = f.read() with Image(blob = image_blob) as img: print("width = ", img.width) print("height = ", img.height) - How to convert wand image object to open cv image (numpy array) -- https://stackoverflow.com/questions/37015966/how-to-convert-wand-image-object-to-open-cv-image-numpy-array/37032551#37032551 from wand.image import Image as WandImage from wand.color import Color import numpy import cv2 RESOLUTION=72 source_file='rose:' img_buffer=None with WandImage(filename=source_file, resolution=(RESOLUTION,RESOLUTION)) as img: img.background_color = Color('white') img.format = 'tif' img.alpha_channel = False # Fill image buffer with numpy array from blob img_buffer=numpy.asarray(bytearray(img.make_blob()), dtype=numpy.uint8) if img_buffer is not None: retval = cv2.imdecode(img_buffer, cv2.IMREAD_UNCHANGED) * 別物 [#tcb4e402] > pip install magickwand - http://digitalarchitekt.de/contributions/magickwand |