mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-03 11:23:05 +03:00
Flags to force libtiff read/write
This commit is contained in:
parent
65e3bfaf33
commit
16c95fc295
|
@ -54,6 +54,9 @@ import collections
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
READ_LIBTIFF = False
|
||||||
|
WRITE_LIBTIFF= False
|
||||||
|
|
||||||
II = b"II" # little-endian (intel-style)
|
II = b"II" # little-endian (intel-style)
|
||||||
MM = b"MM" # big-endian (motorola-style)
|
MM = b"MM" # big-endian (motorola-style)
|
||||||
|
|
||||||
|
@ -760,11 +763,11 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
offsets = self.tag[STRIPOFFSETS]
|
offsets = self.tag[STRIPOFFSETS]
|
||||||
h = getscalar(ROWSPERSTRIP, ysize)
|
h = getscalar(ROWSPERSTRIP, ysize)
|
||||||
w = self.size[0]
|
w = self.size[0]
|
||||||
if self._compression in ["tiff_ccitt", "group3", "group4",
|
if READ_LIBTIFF or self._compression in ["tiff_ccitt", "group3", "group4",
|
||||||
"tiff_jpeg", "tiff_adobe_deflate",
|
"tiff_jpeg", "tiff_adobe_deflate",
|
||||||
"tiff_thunderscan", "tiff_deflate",
|
"tiff_thunderscan", "tiff_deflate",
|
||||||
"tiff_sgilog", "tiff_sgilog24",
|
"tiff_sgilog", "tiff_sgilog24",
|
||||||
"tiff_raw_16"]:
|
"tiff_raw_16"]:
|
||||||
## if Image.DEBUG:
|
## if Image.DEBUG:
|
||||||
## print "Activating g4 compression for whole file"
|
## print "Activating g4 compression for whole file"
|
||||||
|
|
||||||
|
@ -918,12 +921,12 @@ def _save(im, fp, filename):
|
||||||
ifd = ImageFileDirectory(prefix)
|
ifd = ImageFileDirectory(prefix)
|
||||||
|
|
||||||
compression = im.encoderinfo.get('compression',im.info.get('compression','raw'))
|
compression = im.encoderinfo.get('compression',im.info.get('compression','raw'))
|
||||||
libtiff = compression in ["tiff_ccitt", "group3", "group4",
|
libtiff = WRITE_LIBTIFF or compression in ["tiff_ccitt", "group3", "group4",
|
||||||
"tiff_jpeg", "tiff_adobe_deflate",
|
"tiff_jpeg", "tiff_adobe_deflate",
|
||||||
"tiff_thunderscan", "tiff_deflate",
|
"tiff_thunderscan", "tiff_deflate",
|
||||||
"tiff_sgilog", "tiff_sgilog24",
|
"tiff_sgilog", "tiff_sgilog24",
|
||||||
"tiff_raw_16"]
|
"tiff_raw_16"]
|
||||||
|
|
||||||
# -- multi-page -- skip TIFF header on subsequent pages
|
# -- multi-page -- skip TIFF header on subsequent pages
|
||||||
if not libtiff and fp.tell() == 0:
|
if not libtiff and fp.tell() == 0:
|
||||||
# tiff header (write via IFD to get everything right)
|
# tiff header (write via IFD to get everything right)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user