{"library":"pyobjc-framework-quicklookthumbnailing","title":"PyObjC Framework QuickLookThumbnailing","description":"PyObjC-framework-quicklookthumbnailing provides Python bindings for Apple's QuickLookThumbnailing framework on macOS, allowing developers to generate high-quality thumbnails for various file types programmatically. It is part of the broader PyObjC project, bridging Python with Objective-C frameworks. The current version is 12.1, with new releases typically following macOS SDK updates and Python version changes.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pyobjc-framework-quicklookthumbnailing pyobjc-framework-foundation"],"cli":null},"imports":["from QuickLookThumbnailing import QLThumbnailGenerator","from Foundation import NSURL","from PyObjCTools import AppHelper"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import Foundation\nfrom QuickLookThumbnailing import QLThumbnailGenerator\nfrom PyObjCTools import AppHelper\nimport objc\nimport os\n\n# Create a dummy file for demonstration\nfile_path = \"/tmp/test_pyobjc_thumbnail.txt\"\noutput_path = \"/tmp/pyobjc_thumbnail.png\"\n\nwith open(file_path, \"w\") as f:\n    f.write(\"Hello, PyObjC Thumbnailing!\")\n\nfile_url = Foundation.NSURL.fileURLWithPath_(file_path)\n\n@objc.python_block_into_completion_handler\ndef completion_handler(thumbnail, error):\n    if error:\n        print(f\"Error generating thumbnail: {error}\")\n    elif thumbnail:\n        # thumbnail is an NSImage. Convert to PNG data and save.\n        image_data = thumbnail.TIFFRepresentation()\n        image_rep = Foundation.NSBitmapImageRep.imageRepWithData_(image_data)\n        if image_rep:\n            properties = Foundation.NSDictionary.dictionaryWithObject_forKey_(\n                Foundation.NSNumber.numberWithFloat_(1.0), Foundation.NSImageCompressionFactor\n            )\n            png_data = image_rep.representationUsingType_properties_(\n                Foundation.NSPNGFileType, properties\n            )\n            if png_data:\n                png_data.writeToFile_atomically_(output_path, True)\n                print(f\"Thumbnail saved to {output_path}\")\n            else:\n                print(\"Could not get PNG representation.\")\n        else:\n            print(\"Could not create image representation.\")\n    else:\n        print(\"No thumbnail generated.\")\n    AppHelper.stopEventLoop() # Stop the event loop after completion\n\nprint(f\"Generating thumbnail for {file_path}...\")\n\ngenerator = QLThumbnailGenerator.sharedGenerator()\nthumbnail_size = Foundation.NSSize(width=256, height=256) # Max size for the thumbnail\n\ngenerator.generateBestRepresentationForFile_size_completionHandler_(\n    file_url,\n    thumbnail_size,\n    completion_handler\n)\n\nAppHelper.runEventLoop()\n\n# Clean up dummy files\nif os.path.exists(file_path):\n    os.remove(file_path)\nif os.path.exists(output_path):\n    print(f\"Cleaned up {output_path}\")","lang":"python","description":"This quickstart demonstrates how to generate a thumbnail for a local file using QLThumbnailGenerator. It creates a dummy text file, requests a thumbnail, saves the generated NSImage as a PNG, and then cleans up. Since QuickLookThumbnailing APIs are asynchronous, it utilizes PyObjCTools.AppHelper to manage the event loop until the thumbnail generation is complete.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":null,"pypi_latest":"12.1","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyobjc-framework-quicklookthumbnailing","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyobjc-framework-quicklookthumbnailing","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyobjc-framework-quicklookthumbnailing","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyobjc-framework-quicklookthumbnailing","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyobjc-framework-quicklookthumbnailing","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyobjc-framework-quicklookthumbnailing","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyobjc-framework-quicklookthumbnailing","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyobjc-framework-quicklookthumbnailing","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyobjc-framework-quicklookthumbnailing","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyobjc-framework-quicklookthumbnailing","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}