crawl4ai icon indicating copy to clipboard operation
crawl4ai copied to clipboard

Failed to take screenshot: cannot write mode RGBA as JPEG

Open memorysaver opened this issue 2 years ago • 2 comments

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.

memorysaver avatar Jul 15 '24 13:07 memorysaver

@memorysaver thx for the report, I am checking it

unclecode avatar Jul 16 '24 06:07 unclecode

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

unclecode avatar Jul 27 '24 06:07 unclecode