From fc52f733668c96a0e363b3563345035e35943f73 Mon Sep 17 00:00:00 2001 From: masklinn Date: Mon, 5 Oct 2015 12:27:25 +0200 Subject: [PATCH 1/2] Add warning to tobytes It probably isn't what most developers want. --- PIL/Image.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PIL/Image.py b/PIL/Image.py index f09168708..d8fa6402e 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -647,7 +647,13 @@ class Image(object): def tobytes(self, encoder_name="raw", *args): """ - Return image as a bytes object + Return image as a bytes object. + + .. warning:: + + This method is for raw-ish output, for compressed image + data (e.g. PNG, JPEG) use :meth:`~.save`, with a BytesIO + parameter for in-memory data. :param encoder_name: What encoder to use. The default is to use the standard "raw" encoder. From d8a6a8cc18b3d7f59b9910f24af757ddd6acd426 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Mon, 12 Oct 2015 07:26:58 -0700 Subject: [PATCH 2/2] Reworded warning --- PIL/Image.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index d8fa6402e..c99bd05da 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -651,9 +651,10 @@ class Image(object): .. warning:: - This method is for raw-ish output, for compressed image - data (e.g. PNG, JPEG) use :meth:`~.save`, with a BytesIO - parameter for in-memory data. + This method returns the raw image data from the internal + storage. For compressed image data (e.g. PNG, JPEG) use + :meth:`~.save`, with a BytesIO parameter for in-memory + data. :param encoder_name: What encoder to use. The default is to use the standard "raw" encoder.