Opened 8 years ago

Closed 8 years ago

#5375 closed defect (fixed)

Video thumbnailer relies on function that has been removed from recent PIL

Reported by: ayleph Owned by:
Priority: critical Milestone:
Component: programming Keywords: video, thumbnail, PIL, pillow
Cc: Boris Bobrov Parent Tickets:


A few users have come into IRC to report that their installations fail to process videos with the following error.

File '/srv/', line 396 in process
File '/srv/', line 319 in generate_thumb
File '/srv/', line 136 in capture_thumb
  buffer.extract_dup(0, buffer.get_size()))
File '/usr/lib/python2.7/dist-packages/PIL/', line 2053 in fromstring
  "Please call frombytes() instead.")
Exception: fromstring() has been removed. Please call frombytes() instead.

Change History (3)

comment:1 by ayleph, 8 years ago

Cc: Boris Bobrov added
Status: newreview

The change below appears to address this issue. It works on my instance using Pillow==2.5.3 (old), Pillow==2.7.0 (recent), and Pillow==3.0.0 (current as of this post), so I think it's safe to apply. Without the change below, video files fail to process with Pillow=3.0.0 with the same error described in this issue.

CCing breton and requesting review.

From f30cfd5963a066ae6e05e22a7353ba1e5bac42f4 Mon Sep 17 00:00:00 2001
From: ayleph <>
Date: Thu, 17 Dec 2015 21:06:42 -0500
Subject: [PATCH] Fix Issue 5375 Deprecated function in video thumb

This patch fixes issue 5375 by replacing a function call that has
been removed in recent versions of PIL with the recommended
 mediagoblin/media_types/video/ | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mediagoblin/media_types/video/ b/mediagoblin/media_types/video/
index 57912c5..f802049 100644
--- a/mediagoblin/media_types/video/
+++ b/mediagoblin/media_types/video/
@@ -132,7 +132,7 @@ def capture_thumb(video_path, dest_path, width=None, height=None, percent=0.5):
     buffer = sample.get_buffer()

     # get the image from the buffer and save it to disk
-    im = Image.fromstring('RGB', (width, height),
+    im = Image.frombytes('RGB', (width, height),
                          buffer.extract_dup(0, buffer.get_size()))'thumbnail saved to {0}'.format(dest_path))

comment:2 by Boris Bobrov, 8 years ago

Great! Applied to stable and master and pushed. Thank you very much.

comment:3 by Boris Bobrov, 8 years ago

Priority: majorcritical
Resolution: fixed
Status: reviewclosed
Note: See TracTickets for help on using tickets.