unclecode / crawl4ai

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

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

Closed memorysaver closed 3 months ago

memorysaver commented 4 months 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 4 months ago

@memorysaver thx for the report, I am checking it

unclecode commented 3 months ago

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