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

Timelapse previews not generated with Pillow 10.0.0 #917

Closed
CodedSakura opened this issue Jul 13, 2023 · 24 comments
Closed

Timelapse previews not generated with Pillow 10.0.0 #917

CodedSakura opened this issue Jul 13, 2023 · 24 comments

Comments

@CodedSakura
Copy link

Version of Octolapse

Octolapse Version: 0.4.3

Version of OctoPrint

OctoPrint Version: 1.9.1

When you ran into the problem, did you have diagnostic logging enabled?

Diagnostic Logging was Enabled: yes

What were you doing when the problem occurred

  1. Install OctoPi (1.0.0) on a raspberry Pi (3B+)
  2. Add Octolapse plugin to OctoPrint
  3. Configure Octolapse
  4. Start printing with Octolapse enabled

What should have happened?

Timelapse preview should display the last snapshot

What happened instead?

Timelapse preview says "No snapshots have been taken...", but the Sanpshot Count displays a non-zero number.
The timelapse also renders succesfully after print finishes.

Self diagnosis of the problem

Looking at the plugin_oclolapse.log file, at line 2202 it is visible that Octolapse failed to generate a thumbnail
from the snapshot. This seems to be caused by PIL, as the error says AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'.

Python version: 3.9.2
Pillow version: 10.0.0

PIL.Image.ANTIALIAS was incidentally removed in Pillow 10.0.0, but was already deprecated for a while.

This issue repeats for each time Octolapse tries to generate a preview. (L2202, L3560, L4898, L6198, L7480)

Operating System running OctoPrint and Octolapse

OS Name: OctoPi
Os Version: 1.0.0

Printer model & used firmware incl. version

Printer Model: Not needed, internal python problem
Printer Firmware Version: Not needed, internal python problem

Browser and version of browser, operating system running browser

Browser: Not needed, internal python problem
Browser OS: Not needed, internal python problem

Link to the gcode file you were printing when the problem occurred

Link to Gcode File: Not needed, internal python problem

Link to settings.json

Link to settings.json with all passwords removed: Not needed, internal python problem

Link to plugin_octolapse.log

Link to plugin_octolapse.log: https://gist.github.com/CodedSakura/a89dc65a8812503ded1f6fdcca5c2314

Link to octoprint.log

Link to octoprint.log: https://gist.github.com/CodedSakura/0ffe7486151dbe59dc29534f4054deaa

Link to contents of Javascript console in the browser

Link to javascript console output: Not needed, internal python problem

Screenshots and/or videos of the problem:

Screenshot/Video Links:
Screenshot_20230713_142323

Please consider becoming a patron

If you like this project, please support my work by becoming a patron, and consider adding a 'star' to the repository. It takes a lot of time and effort to maintain the project and respond to issues. The cost of test prints, software, cameras, printer parts, etc. can quickly add up, so every bit helps.

You can find various videos and tutorials by subscribing to my Youtube channel. You can also follow me on Twitter.

@IntenseWiggling
Copy link

Encountered this as well, and was able to fix this by updating snapshot.py, replacing Image.ANTIALIAS with Image.Resampling.LANCZOS.

Ref:
https://pillow.readthedocs.io/en/stable/releasenotes/2.7.0.html#antialias-renamed-to-lanczos
python-pillow/Pillow#6200

@rsteckler
Copy link

confirmed the above change works.

@Loeffelmaster
Copy link

Hi,
might be a dumb question, but what do I need to do? Install the sane plugin? Rename the Image.ANTIALIAS file to Image.Resampling.LANCZOS?
I'm a bit confused.
Thanks

Yours
Loeffel

@xXxH3LP3RxXx
Copy link

confirmed the above change works.

Same issue here, but i don't know how to make this change, any short tutorial?

@Loeffelmaster
Copy link

Loeffelmaster commented Aug 8, 2023

confirmed the above change works.

Same issue here, but i don't know how to make this change, any short tutorial?

I found it while searching for something else. You need to edit a file on your Octoprint system.
I think it is /boot/octopi.txt but I'm not sure and I can't have look at the moment I have no access to my system and I can access it earliest in 7-14 days. In this file you need to change the entry accordingly. So you don't need to rename any file.

@xXxH3LP3RxXx
Copy link

I found it while searching for something else. You need to edit a file on your Octoprint system. I think it is /boot/octopi.txt but I'm not sure and I can't have look at the moment I have no access to my system and I can access it earliest in 7-14 days. In this file you need to change the entry accordingly. So you don't need to rename any file.

Thought i need to change the name in snapshot.py itself, but wasn't able to find it, also on octopi.txt i wasnt able to find anything, there are just some settings for the webcam Octopi.txt

@Loeffelmaster
Copy link

I need to have a look, but at the moment I'm in hospital so, that isn't that easy.

@gnodabb
Copy link

gnodabb commented Aug 8, 2023

confirmed the above change works.

Same issue here, but i don't know how to make this change, any short tutorial?

Fairly easy fix. If you open the octolapse log file you will see exactly where the error is located. Here is what I did.

  1. ssh to octopi
  2. cat or less plugin_octolapse.log (this will show where the error is occurring in the python code
  3. using your favorite editor, change Image.ANTIALIAS file to Image.Resampling.LANCZOS
$ ssh username@octopi
$ less ~/.octoprint/logs/plugin_octolapse.log

you should see something like this:

YYYY-MM-DD hh:mm:ss,m - octolapse.snapshot - ERROR - An unexpected exception occurred while post-processing images for the Webcam - Default OctoPi 0.16.0 camera.  See plugin.octolapse.log for details
Traceback (most recent call last):
  File "~/oprint/lib/python3.9/site-packages/octoprint_octolapse/snapshot.py", line 485, in create_thumbnail
    img.thumbnail([basewidth, hsize], Image.ANTIALIAS)
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

Next edit the file shown in the error. Should be the line number shown above.

$ vi ~/oprint/lib/python3.9/site-packages/octoprint_octolapse/snapshot.py

As mentioned above: `Rename the Image.ANTIALIAS file to Image.Resampling.LANCZOS'.
That should get you there.

@xXxH3LP3RxXx
Copy link

Fairly easy fix. If you open the octolapse log file you will see exactly where the error is located. Here is what I did.

That should get you there.

Thanks for that one, will try it out.

I need to have a look, but at the moment I'm in hospital so, that isn't that easy.

Doesn't sound that good, get well soon :)

@mattaster
Copy link
Contributor

I've submitted a Pull Request to update this directly in the plugin. When testing with my local machine everything works great now.

@rickgode
Copy link

I tried the less ~/.octoprint/logs/plugin_octolapse.log but didn't have any errors. So I guess mine isn't the same issue. What I'm seeing is my timelapse preview is of something I printed before the last update. It won't change. Although the plugin seems to be working after the last update. Thoughts?

Ricky

@xXxH3LP3RxXx
Copy link

I tried the less ~/.octoprint/logs/plugin_octolapse.log but didn't have any errors. So I guess mine isn't the same issue. What I'm seeing is my timelapse preview is of something I printed before the last update. It won't change. Although the plugin seems to be working after the last update. Thoughts?

Ricky

Can u upload the octolapse log?

Also i did this "fix" today & the preview is now working👍🏼

@rickgode
Copy link

Mine doesn't seem to be the same issue, it just doesn't update the preview. The image is from the last print before I updated octolapse to the latest version

I've uninstalled octolapse and will attempt reinstalling it.

plugin_octolapse.log
octoprint.log

@xXxH3LP3RxXx
Copy link

Mine doesn't seem to be the same issue, it just doesn't update the preview. The image is from the last print before I updated octolapse to the latest version

I've uninstalled octolapse and will attempt reinstalling it.

plugin_octolapse.log octoprint.log

Could be still the same issue, that log is pretty clean, did you log everything/errors? And start a print with it?

@mattaster
Copy link
Contributor

This seems like a different issue than #917, I'd suggest a new issue to keep things clean.

@rickgode
Copy link

I can confirm now, that my issue was the same others on this thread and the renaming the Image.ANTIALIAS to Image.Resampling.LANCZOS did the trick, but mine was a tad different (and I am total n00b in Linux) Oh and vi is the DEVIL

I typed in the less ~/.octoprint/logs/plugin_octolapse.log and got a similar message as the above post at line 485, but my location of the snapshot.py was different so I had to type the stuff below to find it

vi /home/pi/OctoPrint/venv/lib/python3.8/site-packages/octoprint_octolapse/snapshot.py

Then the arrow keys and such don't work the same in vi (because it's the DEVIL)

So I actually edited it in nano like this

nano /home/pi/OctoPrint/venv/lib/python3.8/site-packages/octoprint_octolapse/snapshot.py

Thanks!

@gnodabb
Copy link

gnodabb commented Aug 31, 2023

Glad you were able to find and fix the issue!

Oh and vi is the DEVIL

lol... First time using it is definitely an awakening. The nice thing about vi is that it's always there. And, if you use it daily you get used to it very fast.

@3dflea
Copy link

3dflea commented Oct 17, 2023

Just to update, according to google Image.Resampling.LANCZOS is also now depreciated as of Pillow 10.0 and should be replaced with Image.LANCZOS

From Google Bard -

No, Image.Resampling.LANCZOS and Image.LANCZOS are not the same. Image.Resampling.LANCZOS was introduced in Pillow 9.0.0 as a new way to specify resampling filters, while Image.LANCZOS was the original way to specify the Lanczos resampling filter. However, Image.Resampling.LANCZOS was deprecated in Pillow 10.0.0, and Image.LANCZOS is now the recommended way to specify the Lanczos resampling filter

@idaband
Copy link

idaband commented Nov 8, 2023

This fixed the issue for me as well. Will this be implemented in the next release by chance?

@ninjamojo
Copy link
Contributor

Going to try to get this added today. I think there is a PR I need to merge.

@idaband
Copy link

idaband commented Nov 9, 2023

Going to try to get this added today. I think there is a PR I need to merge.

awesome saw the change in the release this issue can be resolved.

@FormerLurker
Copy link
Owner

Thanks for responding @idaband! @CodedSakura or anyone else, can you verify the issue is resolved after updating to the latest release?

@CodedSakura
Copy link
Author

can confirm, the issue is fixed in the latest release!

@xamiell
Copy link

xamiell commented Feb 29, 2024

Hi,
Having this issue creating thumbnails

Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.9/site-packages/octoprint_octolapse/snapshot.py", line 339, in process
    self.create_thumbnail()
  File "/home/pi/oprint/lib/python3.9/site-packages/octoprint_octolapse/snapshot.py", line 484, in create_thumbnail
    raise SnapshotError(
octoprint_octolapse.snapshot.SnapshotError: snapshot-thumbnail-create-error: Create Thumbnail - An unexpected exception occurred while creating a snapshot thumbnail for the Webcam - Default OctoPi 0.16.0 camera.  Check the log file (plugin_octolapse.log) for details. - Inner Exception: module 'PIL.Image' has no attribute 'ANTIALIAS'

Printing does not start unless you turn off Octolapse. As I see it happens in gcode files that have tumbnails.

OctoPi new camera stack 1.0.0
OctoPrint 1.9.3
Python 3.9.2
Log:
plugin_octolapse.log

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

No branches or pull requests