unclecode / crawl4ai

🔥🕷️ Crawl4AI: Open-source LLM Friendly Web Crawler & Scrapper
Apache License 2.0
2.01k stars 186 forks source link

Failed to take screenshot: cannot write mode RGBA as JPEG #57

Closed memorysaver closed 1 month ago

memorysaver commented 1 month ago

I use poetry to install crewl4ai with the following version

python = ">=3.11,<3.12"
crawl4ai = {git = "https://github.com/unclecode/crawl4ai.git", extras = ["all"]}

and use the example code to screenshot a demo page and wrap into a fastapi endpoint

class ScreenshotQuery(BaseModel):
    url: str

def create_crawler():
    crawler = WebCrawler(verbose=True)
    crawler.warmup()
    return crawler

crawler = create_crawler()

@app.get("/screenshot_website")
def screenshot_website(query: ScreenshotQuery):
    result = crawler.run(
        url=query.url,
        screenshot=True,
        bypass_cache=True,
        # user_agent="Mozilla/5.0",
    )

I got this error

Failed to take screenshot: cannot write mode RGBA as JPEG.

It seems indicates that the image you are trying to save in JPEG format has an alpha channel (transparency), which JPEG does not support.

unclecode commented 1 month ago

@memorysaver thx for the report, I am checking it

unclecode commented 1 month ago

@memorysaver This is resolved and will be available in version 0.2.76 soon