Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIx for ANTIALIAS being deprecated in Pillow 10.0.0 #1

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

NeoMod
Copy link

@NeoMod NeoMod commented Aug 6, 2023

ANTIALIAS function was removed in Pillow 10.0.0. The new function is called LANCZOS and has the same effect.

This fix introduces the new function in the script so that it can still be used with the latest version of HomeAssistant (Home Assistant 2023.8.1 Supervisor 2023.07.1 Operating System 10.4 Frontend 20230802.0).

The code has been tested and verified to work.

(I don't know if it may be useful but there is a mention of the change introduced in the README too, to make it easier to find)

Fix for ANTIALIAS function beeing removed in Pillow 10.0.0 (after being deprecated through many previous versions). The same function is now called trough PIL.Image.LANCZOS or PIL.Image.Resampling.LANCZOS.
Update image_processing.py to provide a fix for ANTIALIAS function being removed in Pillow 10.0.0
@ovizii
Copy link

ovizii commented Sep 21, 2023

Any progress with this pull request?
This is unusable until fixed :-(

@NeoMod
Copy link
Author

NeoMod commented Sep 21, 2023

@ovizii It seems this project is not under active development, or at least not actively monitored.

You can use my version of the component which incorporates the fix (https://github.com/NeoMod/CodeProject.AI-HomeAssist-ObjectDetect/releases/tag/pillow-updated ): usage is same, nothing else is changed; place the component folder inside your custom components folder and restart your HA instance. It should be good to go.

@ovizii
Copy link

ovizii commented Sep 21, 2023

@NeoMod thanks! I assume I need to manually install while this "original" project could be installed via HACS, right?

Do I need to remove the original or could I possibly just overwrite it with your version?

###edit
never mind, it was really easy.

@NeoMod
Copy link
Author

NeoMod commented Sep 21, 2023

@ovizii you can actually install it trough HACS, but since I haven't had time to modify it's description it would probably detect it as a duplicate of the "original". If you want to let HACS manage the installation, I would suggest removing the "original" and then installing the fixed version.

Otherwise, if you want to proceed manually you can overwrite the original files: it should be a "drop-in replacement" ready to use.

edit: I've added HACS compatibility to the repo, now it should display properly the readme and also have a minor version number so it can be differentiated from the original component. Also, I've fixed a typo: "HACS" not "HASS". sorry.

p.s. glad you managed to have it working. :)

Changed the description and bumped the version to allow users to install this via HASS without conflicts with the "original" version. The documentation link has been updated to point to this repo for clarity and transparency.
added hacs file to render description inside HA
splitted readme to create a simpler version to show inside HACS
@samreuz
Copy link

samreuz commented Dec 24, 2023

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:698
First occurred: 19:55:20 (384 occurrences)
Last logged: 20:57:20

Update for image_processing.codeproject_ai_object_192_168_100_44 fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 698, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 959, in async_device_update
await self.async_update()
File "/usr/src/homeassistant/homeassistant/components/image_processing/init.py", line 193, in async_update
await self.async_process_image(image.content)
File "/usr/src/homeassistant/homeassistant/components/image_processing/init.py", line 174, in async_process_image
return await self.hass.async_add_executor_job(self.process_image, image)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/codeproject_ai_object/image_processing.py", line 347, in process_image
self._image.thumbnail(newsize, Image.ANTIALIAS)
^^^^^^^^^^^^^^^
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

Чтобы исправить эту ошибку, вам нужно будет изменить код кастомного компонента.

Измените строку в файле image_processing.py вашего кастомного компонента:

с этого "self._image.thumbnail(newsize, Image.ANTIALIAS)"

на это "self._image.thumbnail(newsize, Image.Resampling.LANCZOS)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants