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
{{ message }}
Repository navigation
Using Image.show() fails because the temporary file written does not exist #5968
I am using the below code (with show_image=True) to show an image. Works with Pillow==8.4.0 but fails with Pillow==9.0.0. The image viewer applications opens up but the temporary file that Pillow produces is not there.
def show_detections(output_path, show_image, image, scored_boxes_by_class_index, class_index_to_name):
# Draw all results
ctx = ImageDraw.Draw(image, mode = "RGBA")
color_idx = 0
for class_index, scored_boxes in scored_boxes_by_class_index.items():
for i in range(scored_boxes.shape[0]):
scored_box = scored_boxes[i,:]
class_name = class_index_to_name[class_index]
text = "%s %1.2f" % (class_name, scored_box[4])
color = _class_to_color(class_index = class_index)
_draw_rectangle(ctx = ctx, corners = scored_box[0:4], color = color, thickness = 2)
_draw_text(image = image, text = text, position = (scored_box[1], scored_box[0]), color = color, scale = 1.5, offset_lines = -1)
# Output
if show_image:
image.show()
if output_path is not None:
image.save(output_path)
print("Wrote detection results to '%s'" % output_path)
Inserting a sleep thereafter doesn't help.
What did you expect to happen?
The temporary file should be present and the application should be able to view it.
Hi. There is already an issue open for this - #5945.
What application is opening?
Inserting sleep in your code wouldn't work, but some users in that other thread have found that inserting sleep into Pillow's code works. Is that what you've tried? What values have you tried?
Activity
radarhere commentedon Jan 17, 2022
Hi. There is already an issue open for this - #5945.
What application is opening?
Inserting sleep in your code wouldn't work, but some users in that other thread have found that inserting sleep into Pillow's code works. Is that what you've tried? What values have you tried?
trzy commentedon Jan 18, 2022
Ah, sorry, didn't realize. I've tried a sleep of as high as 5 seconds. The image viewer is just the default GNOME image viewer in Ubuntu.
radarhere commentedon Feb 3, 2022
Pillow 9.0.1 has just been released, and should resolve this. Let us know if it does not.