mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 02:16:19 +03:00
The JPEG plug-in will seek the stream if it's an fd, so change to using an io.BytesIO.
This commit is contained in:
parent
5f77c39090
commit
18f12b30aa
|
@ -16,7 +16,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
from PIL import Image, ImageFile, PngImagePlugin, Jpeg2KImagePlugin, _binary
|
from PIL import Image, ImageFile, PngImagePlugin, Jpeg2KImagePlugin, _binary
|
||||||
import struct
|
import struct, io
|
||||||
|
|
||||||
i8 = _binary.i8
|
i8 = _binary.i8
|
||||||
|
|
||||||
|
@ -103,7 +103,9 @@ def read_png_or_jpeg2000(fobj, start_length, size):
|
||||||
or sig == b'\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a':
|
or sig == b'\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a':
|
||||||
# j2k, jpc or j2c
|
# j2k, jpc or j2c
|
||||||
fobj.seek(start)
|
fobj.seek(start)
|
||||||
im = Jpeg2KImagePlugin.Jpeg2KImageFile(fobj)
|
jp2kstream = fobj.read(length)
|
||||||
|
f = io.BytesIO(jp2kstream)
|
||||||
|
im = Jpeg2KImagePlugin.Jpeg2KImageFile(f)
|
||||||
if im.mode != 'RGBA':
|
if im.mode != 'RGBA':
|
||||||
im = im.convert('RGBA')
|
im = im.convert('RGBA')
|
||||||
return {"RGBA": im}
|
return {"RGBA": im}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user