Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odgovori
1856 Prikazi

Im trying to import a lot of .webp images to my products using an URL, however I keep getting this error:

cannot identify image file  _io.BytesIO object at 0x7fa789b18090


It works fine with jpg and png, however i need them to be .webp format.


I tried converting the images to base64 and importing the strings instead, however as my base64 images are ~200k characters it can't fit in a csv/excel cell. 


Does anyone have a solution for this?

Avatar
Opusti
Best Answer

This error happens because the image library Odoo uses (Pillow/PIL) doesn't recognize the WebP format. While Pillow does support WebP, many Odoo installations don’t have this support enabled by default (it depends on whether the libwebp library is installed on the server).

Why does it work with JPG/PNG but not WebP?
  • JPG and PNG are natively supported by Pillow.
  • WebP requires Pillow to be compiled with libwebp support. If it's missing, you’ll get errors like the one you reported.
Possible solutions
  1. Enable WebP support on the server
    • If you have access to the Odoo server, install libwebp and reinstall Pillow:


      sudo apt-get install libwebp-dev pip3 uninstall pillow pip3 install --no-cache-dir pillow

      This will enable WebP support and allow you to import images from URLs directly.
  2. Convert the images before importing
    • If you cannot change the server setup, the most stable option is to convert the WebP images to JPG/PNG using a pre-processing script (e.g., with cwebp or ImageMagick) and then import them.
  3. Import images as base64 but without using CSV
    • If the problem is the character limit in CSV/Excel, you can upload images via XML or using a Python script through Odoo's API (xmlrpc or jsonrpc). This avoids the cell limit issue.
    Example using the API:


    import base64 import requests image_url = "https://example.com/image.webp" image_data = base64.b64encode(requests.get(image_url).content).decode('utf-8') models.execute_kw(db, uid, password, 'product.template', 'write', [[product_id], {'image_1920': image_data}])

Recommendation

If you have access to the server, enabling WebP support in Pillow is the easiest fix. Otherwise, convert your images to JPG/PNG or use an alternative import method (script/API) to bypass the CSV cell limit.

Avatar
Opusti
Best Answer

Hi Anders

can you check if you have the right pillow version installed?

try to uninstall it and install it again. Looks from the first view an error occurring from pillow library

I will make another test, debug and come back to you, if the recommendation above, does not solve the problem. (could be that at the end, you have to create a ticket to odoo suppport)

Avatar
Opusti

Hi Daniel, I’m having the same issue in Odoo 18 SaaS, so I guess that’s something that Odoo has to fix on their end?

Good input, than yes
Please create a ticket to odoo, and submit at best, a video showing the issue in runbot
Thank you for your contribution

Hello, Daniel. I attempted to resolve this by adding the Pillow version to the requirements.txt file “Pillow>=10.0” and creating the apt.txt file with the text “libwebp-dev,” but it still does not function. Is there another way to resolve this?

Best Answer

Hi Anders,

Having the same issue in Odoo 18. Were you able to solve it?

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
0
avg. 24
1160
1
jun. 24
1425
2
dec. 23
1703
1
mar. 15
3339
0
mar. 25
971