mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
force seek to beginning of file
This commit is contained in:
parent
1540d46ca9
commit
7d99141405
|
@ -114,17 +114,6 @@ def test_g4_tiff_bytesio():
|
|||
assert_equal(im.size, (500,500))
|
||||
_assert_noerr(im)
|
||||
|
||||
def xtest_g4_tiff_fail(): # UNDONE fails badly, unknown reason
|
||||
"""The 128x128 lena image fails for some reason. Investigating"""
|
||||
|
||||
Image.DEBUG = True
|
||||
file = "Tests/images/lena_g4.tif"
|
||||
im = Image.open(file)
|
||||
|
||||
assert_equal(im.size, (128,128))
|
||||
_assert_noerr(im)
|
||||
Image.DEBUG = False
|
||||
|
||||
def test_g4_eq_png():
|
||||
""" Checking that we're actually getting the data that we expect"""
|
||||
png = Image.open('Tests/images/lena_bw_500.png')
|
||||
|
@ -134,7 +123,6 @@ def test_g4_eq_png():
|
|||
|
||||
def test_g4_write():
|
||||
"""Checking to see that the saved image is the same as what we wrote"""
|
||||
Image.DEBUG = True
|
||||
|
||||
file = "Tests/images/lena_g4_500.tif"
|
||||
orig = Image.open(file)
|
||||
|
@ -151,4 +139,3 @@ def test_g4_write():
|
|||
|
||||
assert_false(orig.tobytes() == reread.tobytes())
|
||||
|
||||
Image.DEBUG = False
|
||||
|
|
47
Tests/test_lena.py
Normal file
47
Tests/test_lena.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
from tester import *
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from test_file_tiff import _assert_noerr
|
||||
|
||||
""" The small lena image was failing on open in the libtiff
|
||||
decoder because the file pointer was set to the wrong place
|
||||
by a spurious seek. It wasn't failing with the byteio method.
|
||||
|
||||
It was fixed by forcing an lseek to the beginning of the
|
||||
file just before reading in libtiff. These tests remain
|
||||
to ensure that it stays fixed. """
|
||||
|
||||
|
||||
def test_g4_lena_file():
|
||||
"""Testing the open file load path"""
|
||||
|
||||
file = "Tests/images/lena_g4.tif"
|
||||
with open(file,'rb') as f:
|
||||
im = Image.open(f)
|
||||
|
||||
assert_equal(im.size, (128,128))
|
||||
_assert_noerr(im)
|
||||
|
||||
def test_g4_lena_bytesio():
|
||||
"""Testing the bytesio loading code path"""
|
||||
from io import BytesIO
|
||||
file = "Tests/images/lena_g4.tif"
|
||||
s = BytesIO()
|
||||
with open(file,'rb') as f:
|
||||
s.write(f.read())
|
||||
s.seek(0)
|
||||
im = Image.open(s)
|
||||
|
||||
assert_equal(im.size, (128,128))
|
||||
_assert_noerr(im)
|
||||
|
||||
def test_g4_lena():
|
||||
"""The 128x128 lena image fails for some reason. Investigating"""
|
||||
|
||||
file = "Tests/images/lena_g4.tif"
|
||||
im = Image.open(file)
|
||||
|
||||
assert_equal(im.size, (128,128))
|
||||
_assert_noerr(im)
|
||||
|
|
@ -199,6 +199,7 @@ int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, int
|
|||
dump_state(clientstate);
|
||||
if (clientstate->fp) {
|
||||
TRACE(("Opening using fd: %d\n",clientstate->fp));
|
||||
lseek(clientstate->fp,0,SEEK_SET); // Sometimes, I get it set to the end.
|
||||
tiff = TIFFFdOpen(clientstate->fp, filename, mode);
|
||||
} else {
|
||||
TRACE(("Opening from string\n"));
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
#include <tiff.h>
|
||||
#endif
|
||||
|
||||
#ifndef _UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef min
|
||||
#define min(x,y) (( x > y ) ? y : x )
|
||||
#define max(x,y) (( x < y ) ? y : x )
|
||||
|
@ -50,8 +55,8 @@ extern int ImagingLibTiffSetField(ImagingCodecState state, ttag_t tag, ...);
|
|||
/*
|
||||
#define TRACE(args)
|
||||
*/
|
||||
#endif
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user