[Windows Only]: R8 Parameter is not valid to create System.Drawing.Bitmap

Hey all, it doesn’t seem like I can call System.Drawing.Bitmap like the snippet below on Windows. However, the same code works on macOS. How can I fix it? Thanks!

            web_client = System.Net.WebClient()
            image_data = web_client.DownloadData(image_url)

            # Convert to a Bitmap
            memory_stream = System.IO.MemoryStream(image_data)
            bitmap = System.Drawing.Bitmap(memory_stream)

Hi @Steven_Nie,

The following code works on my end on Windows:

#! python3
import System

image_url = r"https://global.discourse-cdn.com/mcneel/original/3X/3/6/36bfa7aa69160ae4bb6e6d46fea7a7516e4c8fb8.png"

web_client = System.Net.WebClient()
image_data = web_client.DownloadData(image_url)

# Convert to a Bitmap
memory_stream = System.IO.MemoryStream(image_data)
bitmap = System.Drawing.Bitmap(memory_stream)

print(f"Bitmap Info: {bitmap} {bitmap.Size}")

If you run this code, what do you get returned on your end?

1 Like

Ah it turns out webp file is not supported on Windows. Thank you Michael!

1 Like

Thanks for sharing that information, that is good to know!