{"library":"standard-imghdr","title":"Standard imghdr Library","type":"library","description":"The `standard-imghdr` library is a redistribution of the `imghdr` module, which was formerly part of the Python standard library. It provides functionality to determine the type of an image file based on its header. Maintained by the `python-deadlib` project, this library serves as a compatibility layer for projects that relied on `imghdr` after its deprecation in Python 3.11 and subsequent removal in Python 3.13. The current version is 3.13.0 and it follows an infrequent release cadence focused on maintaining compatibility.","language":"python","status":"maintenance","last_verified":"Fri May 15","install":{"commands":["pip install standard-imghdr"],"cli":null},"imports":["import imghdr"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/youknowone/python-deadlib","docs":null,"changelog":null,"pypi":"https://pypi.org/project/standard-imghdr/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import imghdr\nimport os\n\n# Create a dummy JPEG file for demonstration\ndummy_jpeg_data = b'\\xFF\\xD8\\xFF\\xE0\\x00\\x10JFIF\\x00\\x01\\x01\\x00\\x00\\x01\\x00\\x01\\x00\\x00\\xFF\\xDB\\x00C\\x00\\x08\\x06\\x06\\x07\\x06\\x05\\x08\\x07\\x07\\x07\\x09\\x09\\x08\\x0A\\x0C\\x14\\x0D\\x0C\\x0B\\x0B\\x0C\\x19\\x12\\x13\\x0F\\x14\\x1D\\x1A\\x1F\\x1E\\x1D\\x1A\\x1C\\x1C\\x20\\x24\\x2E\\x27\\x20\\x22\\x2C\\x23\\x1C\\x1C\\x28\\x37\\x29\\x2B\\x30\\x31\\x30\\x33\\x31\\x2F\\x36\\x2E\\x37\\x39\\x3D\\x3B\\x3A\\x32\\x38\\x37\\x3D\\x36\\x36\\x38\\x37\\x20\\x20'\ndummy_png_data = b'\\x89PNG\\r\\n\\x1a\\n\\x00\\x00\\x00\\rIHDR\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x01\\x08\\x06\\x00\\x00\\x00\\x1f\\x15\\xc4\\x89\\x00\\x00\\x00\\x0cIDATx\\xda\\xed\\xc1\\x01\\x01\\x00\\x00\\x00\\xc2\\xa0\\xf7Om\\x00\\x00\\x00\\x00IEND\\xaeB`\\x82'\n\n# Create temporary files\nwith open('test_image.jpg', 'wb') as f:\n    f.write(dummy_jpeg_data)\nwith open('test_image.png', 'wb') as f:\n    f.write(dummy_png_data)\n\n# Determine image type by filename\nimage_type_jpg = imghdr.what('test_image.jpg')\nprint(f\"Type of test_image.jpg: {image_type_jpg}\")\n\nimage_type_png = imghdr.what('test_image.png')\nprint(f\"Type of test_image.png: {image_type_png}\")\n\n# Determine image type from a byte stream\nimage_type_bytes = imghdr.what(None, h=dummy_jpeg_data)\nprint(f\"Type of image from bytes: {image_type_bytes}\")\n\n# Clean up temporary files\nos.remove('test_image.jpg')\nos.remove('test_image.png')","lang":"python","description":"This quickstart demonstrates how to use `imghdr.what()` to identify image types from both a filename and a byte stream. It creates temporary dummy JPEG and PNG files, identifies their types, and then cleans up the files.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"3.13.0","pypi_latest":"3.13.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":1.5,"avg_import_s":0,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"standard-imghdr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0,"mem_mb":0.3,"disk_size":"17.8M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"standard-imghdr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.4,"import_time_s":0,"mem_mb":0.3,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"standard-imghdr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":0,"mem_mb":0.3,"disk_size":"19.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"standard-imghdr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":1.6,"import_time_s":0,"mem_mb":0.3,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"standard-imghdr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":0,"mem_mb":0.4,"disk_size":"11.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"standard-imghdr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":1.5,"import_time_s":0,"mem_mb":0.4,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"standard-imghdr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":0.01,"mem_mb":0.4,"disk_size":"11.2M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"standard-imghdr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":1.4,"import_time_s":0.01,"mem_mb":0.2,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"standard-imghdr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0,"mem_mb":0.3,"disk_size":"17.3M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"standard-imghdr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.7,"import_time_s":0,"mem_mb":0.3,"disk_size":"18M"}]}}