mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
commit
d03dde989d
|
@ -25,7 +25,7 @@ import io
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from . import Image, ImageFile
|
from . import Image, ImageFile
|
||||||
from ._binary import i32le as i32, o32le as o32
|
from ._binary import i32le as i32
|
||||||
|
|
||||||
__version__ = "0.5"
|
__version__ = "0.5"
|
||||||
|
|
||||||
|
@ -84,7 +84,6 @@ def Ghostscript(tile, size, fp, scale=1):
|
||||||
float((72.0 * size[1]) / (bbox[3]-bbox[1])))
|
float((72.0 * size[1]) / (bbox[3]-bbox[1])))
|
||||||
# print("Ghostscript", scale, size, orig_size, bbox, orig_bbox, res)
|
# print("Ghostscript", scale, size, orig_size, bbox, orig_bbox, res)
|
||||||
|
|
||||||
import os
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
|
@ -508,7 +508,6 @@ def _save_netpbm(im, fp, filename):
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from subprocess import Popen, check_call, PIPE, CalledProcessError
|
from subprocess import Popen, check_call, PIPE, CalledProcessError
|
||||||
import tempfile
|
|
||||||
file = im._dump()
|
file = im._dump()
|
||||||
|
|
||||||
with open(filename, 'wb') as f:
|
with open(filename, 'wb') as f:
|
||||||
|
|
|
@ -39,7 +39,7 @@ import struct
|
||||||
import io
|
import io
|
||||||
import warnings
|
import warnings
|
||||||
from . import Image, ImageFile, TiffImagePlugin
|
from . import Image, ImageFile, TiffImagePlugin
|
||||||
from ._binary import i8, o8, i16be as i16, i32be as i32
|
from ._binary import i8, o8, i16be as i16
|
||||||
from .JpegPresets import presets
|
from .JpegPresets import presets
|
||||||
from ._util import isStringType
|
from ._util import isStringType
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ import zlib
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from . import Image, ImageFile, ImagePalette
|
from . import Image, ImageFile, ImagePalette
|
||||||
from ._binary import i8, i16be as i16, i32be as i32, o8, o16be as o16, o32be as o32
|
from ._binary import i8, i16be as i16, i32be as i32, o16be as o16, o32be as o32
|
||||||
|
|
||||||
__version__ = "0.9"
|
__version__ = "0.9"
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ class SunImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
def _open(self):
|
def _open(self):
|
||||||
|
|
||||||
# The Sun Raster file header is 32 bytes in length and has the following format:
|
# The Sun Raster file header is 32 bytes in length
|
||||||
|
# and has the following format:
|
||||||
|
|
||||||
# typedef struct _SunRaster
|
# typedef struct _SunRaster
|
||||||
# {
|
# {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
|
|
||||||
from . import Image, ImageFile, ImagePalette
|
from . import Image, ImageFile, ImagePalette
|
||||||
from ._binary import i8, i16le as i16, o8, o16le as o16, o32le as o32
|
from ._binary import i8, i16le as i16, o8, o16le as o16
|
||||||
|
|
||||||
__version__ = "0.3"
|
__version__ = "0.3"
|
||||||
|
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
self.info["dpi"] = xres, yres
|
self.info["dpi"] = xres, yres
|
||||||
elif resunit == 3: # dots per centimeter. convert to dpi
|
elif resunit == 3: # dots per centimeter. convert to dpi
|
||||||
self.info["dpi"] = xres * 2.54, yres * 2.54
|
self.info["dpi"] = xres * 2.54, yres * 2.54
|
||||||
elif resunit == None: # used to default to 1, but now 2)
|
elif resunit is None: # used to default to 1, but now 2)
|
||||||
self.info["dpi"] = xres, yres
|
self.info["dpi"] = xres, yres
|
||||||
# For backward compatibility, we also preserve the old behavior.
|
# For backward compatibility, we also preserve the old behavior.
|
||||||
self.info["resolution"] = xres, yres
|
self.info["resolution"] = xres, yres
|
||||||
|
|
|
@ -167,7 +167,6 @@ class PillowTestCase(unittest.TestCase):
|
||||||
|
|
||||||
outfile = self.tempfile("temp.png")
|
outfile = self.tempfile("temp.png")
|
||||||
if command_succeeds([IMCONVERT, f, outfile]):
|
if command_succeeds([IMCONVERT, f, outfile]):
|
||||||
from PIL import Image
|
|
||||||
return Image.open(outfile)
|
return Image.open(outfile)
|
||||||
raise IOError()
|
raise IOError()
|
||||||
|
|
||||||
|
@ -179,7 +178,6 @@ py3 = (sys.version_info >= (3, 0))
|
||||||
|
|
||||||
def fromstring(data):
|
def fromstring(data):
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from PIL import Image
|
|
||||||
return Image.open(BytesIO(data))
|
return Image.open(BytesIO(data))
|
||||||
|
|
||||||
|
|
||||||
|
@ -191,7 +189,6 @@ def tostring(im, string_format, **options):
|
||||||
|
|
||||||
|
|
||||||
def hopper(mode=None, cache={}):
|
def hopper(mode=None, cache={}):
|
||||||
from PIL import Image
|
|
||||||
if mode is None:
|
if mode is None:
|
||||||
# Always return fresh not-yet-loaded version of image.
|
# Always return fresh not-yet-loaded version of image.
|
||||||
# Operations on not-yet-loaded images is separate class of errors
|
# Operations on not-yet-loaded images is separate class of errors
|
||||||
|
|
|
@ -32,7 +32,7 @@ class TestFileFitsStub(PillowTestCase):
|
||||||
im = Image.open(TEST_FILE)
|
im = Image.open(TEST_FILE)
|
||||||
|
|
||||||
# Act / Assert: stub cannot load without an implemented handler
|
# Act / Assert: stub cannot load without an implemented handler
|
||||||
self.assertRaises(IOError, lambda: im.load())
|
self.assertRaises(IOError, im.load)
|
||||||
|
|
||||||
def test_save(self):
|
def test_save(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
|
|
|
@ -90,8 +90,6 @@ class TestFileGif(PillowTestCase):
|
||||||
check(256, 511, 256)
|
check(256, 511, 256)
|
||||||
|
|
||||||
def test_optimize_full_l(self):
|
def test_optimize_full_l(self):
|
||||||
from io import BytesIO
|
|
||||||
|
|
||||||
im = Image.frombytes("L", (16, 16), bytes(bytearray(range(256))))
|
im = Image.frombytes("L", (16, 16), bytes(bytearray(range(256))))
|
||||||
test_file = BytesIO()
|
test_file = BytesIO()
|
||||||
im.save(test_file, "GIF", optimize=True)
|
im.save(test_file, "GIF", optimize=True)
|
||||||
|
|
|
@ -32,7 +32,7 @@ class TestFileHdf5Stub(PillowTestCase):
|
||||||
im = Image.open(TEST_FILE)
|
im = Image.open(TEST_FILE)
|
||||||
|
|
||||||
# Act / Assert: stub cannot load without an implemented handler
|
# Act / Assert: stub cannot load without an implemented handler
|
||||||
self.assertRaises(IOError, lambda: im.load())
|
self.assertRaises(IOError, im.load)
|
||||||
|
|
||||||
def test_save(self):
|
def test_save(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from helper import unittest, PillowTestCase, hopper, py3
|
from helper import unittest, PillowTestCase, hopper
|
||||||
from helper import djpeg_available, cjpeg_available
|
from helper import djpeg_available, cjpeg_available
|
||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
|
@ -564,20 +564,6 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
# Should not raise UnicodeDecodeError or anything else
|
# Should not raise UnicodeDecodeError or anything else
|
||||||
im.save(outfile)
|
im.save(outfile)
|
||||||
|
|
||||||
def test_page_number_x_0(self):
|
|
||||||
# Issue 973
|
|
||||||
# Test TIFF with tag 297 (Page Number) having value of 0 0.
|
|
||||||
# The first number is the current page number.
|
|
||||||
# The second is the total number of pages, zero means not available.
|
|
||||||
outfile = self.tempfile("temp.tif")
|
|
||||||
# Created by printing a page in Chrome to PDF, then:
|
|
||||||
# /usr/bin/gs -q -sDEVICE=tiffg3 -sOutputFile=total-pages-zero.tif
|
|
||||||
# -dNOPAUSE /tmp/test.pdf -c quit
|
|
||||||
infile = "Tests/images/total-pages-zero.tif"
|
|
||||||
im = Image.open(infile)
|
|
||||||
# Should not divide by zero
|
|
||||||
im.save(outfile)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from helper import unittest, PillowTestCase
|
from helper import unittest, PillowTestCase
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from io import BytesIO
|
|
||||||
|
|
||||||
class TestFileWmf(PillowTestCase):
|
class TestFileWmf(PillowTestCase):
|
||||||
|
|
||||||
|
|
|
@ -343,7 +343,7 @@ class TestImageCms(PillowTestCase):
|
||||||
]
|
]
|
||||||
chans = []
|
chans = []
|
||||||
bands = ImageMode.getmode(mode).bands
|
bands = ImageMode.getmode(mode).bands
|
||||||
for band_ndx, band in enumerate(bands):
|
for band_ndx in range(len(bands)):
|
||||||
channel_type = 'L' # 8-bit unorm
|
channel_type = 'L' # 8-bit unorm
|
||||||
channel_pattern = hopper(channel_type)
|
channel_pattern = hopper(channel_type)
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ class TestImageSequence(PillowTestCase):
|
||||||
for frame in ImageSequence.Iterator(im):
|
for frame in ImageSequence.Iterator(im):
|
||||||
if firstFrame is None:
|
if firstFrame is None:
|
||||||
firstFrame = frame.copy()
|
firstFrame = frame.copy()
|
||||||
pass
|
|
||||||
for frame in ImageSequence.Iterator(im):
|
for frame in ImageSequence.Iterator(im):
|
||||||
self.assert_image_equal(frame, firstFrame)
|
self.assert_image_equal(frame, firstFrame)
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue
Block a user