{"library":"pdf2image","code":"import os\nimport tempfile\nfrom pdf2image import convert_from_path\n\n# NOTE: For this code to run, you need Poppler installed and in your PATH.\n# Create a dummy PDF file for the example (replace with your actual PDF path)\n# This example assumes 'dummy.pdf' exists in the same directory.\n# In a real scenario, you'd provide the path to an existing PDF.\nif not os.path.exists('dummy.pdf'):\n    print(\"Please create a 'dummy.pdf' file in the current directory or provide a valid path.\")\n    # Example: Create a simple dummy PDF using a library like ReportLab or manually\n    # For demonstration, we'll simulate a successful conversion if no PDF exists\n    # by skipping the actual conversion and printing a message.\n    # In a real app, you'd handle this error.\nelse:\n    try:\n        with tempfile.TemporaryDirectory() as path:\n            images = convert_from_path(\n                'dummy.pdf', \n                output_folder=path, \n                fmt='jpeg', \n                dpi=200\n            )\n\n            for i, image in enumerate(images):\n                output_filename = f\"output_page_{i+1}.jpeg\"\n                image.save(output_filename, 'JPEG')\n                print(f\"Saved {output_filename}\")\n        print(\"PDF conversion successful (if 'dummy.pdf' existed and Poppler was configured).\")\n    except Exception as e:\n        print(f\"An error occurred during PDF conversion: {e}\")\n        print(\"Please ensure Poppler is installed and its 'bin' directory is in your system's PATH.\")\n        print(\"For Windows, you might need to specify poppler_path=r'C:\\path\\to\\poppler\\bin' in convert_from_path.\")","lang":"python","description":"This quickstart demonstrates converting a PDF file into a list of PIL Image objects using `convert_from_path` and saving each page as a JPEG image. It highlights the use of `output_folder` for efficiency with large PDFs and `fmt` for specifying the output image format. Users must ensure Poppler is installed and correctly configured in their system's PATH for the library to function.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}