{"library":"ocrmac","title":"ocrmac","description":"ocrmac is a Python wrapper designed to extract text from images specifically on macOS systems. It leverages Apple's Vision framework to provide fast and accurate Optical Character Recognition (OCR) capabilities. The library is currently at version 1.0.1 and maintains an active development and release cadence, with updates addressing features and bug fixes. It requires macOS 10.15 (Catalina) or newer.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install ocrmac"],"cli":null},"imports":["from ocrmac import ocrmac","from ocrmac.ocrmac import OCR"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from ocrmac import ocrmac\nfrom PIL import Image\nimport os\n\n# Create a dummy image for demonstration purposes\ndummy_image_path = 'test_image.png'\nimg = Image.new('RGB', (60, 30), color = 'red')\nfrom PIL import ImageDraw, ImageFont\nd = ImageDraw.Draw(img)\ntry:\n    # Use a system font path for broader compatibility\n    font = ImageFont.truetype(\"/System/Library/Fonts/Supplemental/Arial.ttf\", 12)\nexcept IOError:\n    font = ImageFont.load_default() # Fallback\nd.text((10,10), \"Hello OCR!\", fill=(0,0,0), font=font)\nimg.save(dummy_image_path)\n\n# Perform OCR using the OCR class\ntry:\n    annotations = ocrmac.OCR(dummy_image_path, language_preference=['en-US']).recognize()\n    print(\"Detected annotations:\")\n    for text, confidence, bounding_box in annotations:\n        print(f\"  Text: '{text}', Confidence: {confidence:.2f}, Bounding Box: {bounding_box}\")\n\n    # Alternatively, use the functional interface\n    text_output = ocrmac.text_from_image(dummy_image_path, language_preference=['en-US'])\n    print(\"\\nDetected text (functional interface):\")\n    print(text_output)\n\nfinally:\n    # Clean up the dummy image\n    if os.path.exists(dummy_image_path):\n        os.remove(dummy_image_path)","lang":"python","description":"This quickstart demonstrates how to use `ocrmac` to extract text from an image. It covers both the class-based `ocrmac.OCR` approach and the functional `ocrmac.text_from_image` method, including setting language preferences. A dummy image is created for a runnable example.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}