You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The outer group of this regex should match the header of .ppm files. Sometimes (in the case of my image) it matches not only the header but the full file. When the "header" is then stripped away using offset=len(header) in line 49, no payload is left over and reading the data fails.
So, why is this: Because the regex in its current form tries to capture comments after the last header word 'maxval'. This seems to be disallowed for the binary P6 PPM format:
Comments can only occur before the last field of the header and only one byte may appear after the last header field, normally a carriage return or line feed.
from vapory.io import ppm_to_numpy
with open('problematic_image.ppm', 'rb') as f:
out = f.read()
ppm_to_numpy(buffer=out)
This will lead to the following stacktrace:
File "/opt/python3.7/site-packages/vapory/vapory.py", line 102, in render
quality, antialiasing, remove_temp)
File "/opt/python3.7/site-packages/vapory/io.py", line 117, in render_povstring
return ppm_to_numpy(buffer=out)
File "/opt/python3.7/site-packages/vapory/io.py", line 49, in ppm_to_numpy
offset=len(header))
ValueError: buffer is smaller than requested size
The text was updated successfully, but these errors were encountered:
I found a bug with the regex search expression in lines 36-40 of vapory/io.py:
The outer group of this regex should match the header of .ppm files. Sometimes (in the case of my image) it matches not only the header but the full file. When the "header" is then stripped away using
offset=len(header)
in line 49, no payload is left over and reading the data fails.So, why is this: Because the regex in its current form tries to capture comments after the last header word 'maxval'. This seems to be disallowed for the binary P6 PPM format:
[source: http://paulbourke.net/dataformats/ppm/]
Way to reproduce the bug:
This will lead to the following stacktrace:
The text was updated successfully, but these errors were encountered: