{"id":23372,"library":"blurhash-python","title":"BlurHash Python","description":"A Python implementation of the BlurHash algorithm, which encodes an image into a short, blurry placeholder string. Version 1.2.2 is current, with stable but infrequent releases.","status":"active","version":"1.2.2","language":"python","source_language":"en","source_url":"https://github.com/woltapp/blurhash","tags":["blurhash","image-processing","placeholder","encoding"],"install":[{"cmd":"pip install blurhash-python","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Official import path from the package.","symbol":"encode","correct":"from blurhash import encode"},{"note":"Official import path for decoding.","symbol":"decode","correct":"from blurhash import decode"}],"quickstart":{"code":"from blurhash import encode, decode\nfrom PIL import Image\nimport numpy as np\n\nimg = Image.open('image.jpg').convert('RGB')\narr = np.array(img)\nblurhash_str = encode(1920, 1080, arr)\nprint(blurhash_str)\n\n# Decode back to pixels\npixels = decode(blurhash_str, 32, 32)\nrecreated = Image.fromarray(pixels.astype('uint8'), 'RGB')\nrecreated.show()","lang":"python","description":"Encode an image to a BlurHash string and decode it back to a rough placeholder."},"warnings":[{"fix":"Convert image to a numpy array with dtype uint8 and ensure RGB ordering before calling encode.","message":"The encode function expects pixel data as a 3D numpy array with shape (height, width, 3) and dtype uint8. Passing a list or incorrect shape will raise a TypeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Use decoded_pixels.astype('uint8') before creating an image object.","message":"The decode function returns a numpy array of dtype float64, not uint8. Displaying the image requires casting to uint8 and clipping values between 0 and 255.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure pixels is a numpy array: np.array(Image.open('img.jpg')).astype('uint8') and check shape.","cause":"Passing non-numpy data or incorrect dtype/shape to encode().","error":"TypeError: Argument 'pixels' must be a numpy array with dtype uint8 and shape (height, width, 3)"},{"fix":"Verify the BlurHash string has the correct format (e.g., ~LGFO.?-RM{WB?ofV@WB?ofWBof) and was generated by a compatible encoder.","cause":"Trying to decode an invalid or corrupted BlurHash string.","error":"ValueError: Invalid BlurHash: ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}