Skip to content

Commit

Permalink
TIFF sample format table
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursunny committed Jun 1, 2024
1 parent 90840ae commit 4a80ba9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
17 changes: 6 additions & 11 deletions src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
from .TiffTags import TYPES

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG) # XXX hack202406

# Set these to true to force use of libtiff for reading or writing.
READ_LIBTIFF = False
Expand Down Expand Up @@ -182,11 +183,11 @@
(II, 1, (1,), 1, (12,), ()): ("I;16", "I;12"),
(II, 0, (1,), 1, (16,), ()): ("I;16", "I;16"),
(II, 1, (1,), 1, (16,), ()): ("I;16", "I;16"),
(II, 1, (1,), 1, (16, 16), (0,)): ("I;16", "I;16"),
(II, 1, (1, 1), 1, (16, 16), (0,)): ("I;16", "I;16"),
(
II,
1,
(1,),
(1, 1, 1),
1,
(16, 16, 16),
(
Expand All @@ -197,7 +198,7 @@
(
II,
1,
(1,),
(1, 1, 1, 1),
1,
(16, 16, 16, 16),
(
Expand All @@ -209,7 +210,7 @@
(
II,
1,
(1,),
(1, 1, 1, 1, 1),
1,
(16, 16, 16, 16, 16),
(
Expand Down Expand Up @@ -1416,13 +1417,7 @@ def _setup(self):
logger.debug("- size: %s", self.size)

sample_format = self.tag_v2.get(SAMPLEFORMAT, (1,))
if len(sample_format) > 1 and max(sample_format) == min(sample_format) == 1:
# SAMPLEFORMAT is properly per band, so an RGB image will
# be (1,1,1). But, we don't support per band pixel types,
# and anything more than one band is a uint8. So, just
# take the first element. Revisit this if adding support
# for more exotic images.
sample_format = (1,)
logger.debug("- sample_format: %s", sample_format)

bps_tuple = self.tag_v2.get(BITSPERSAMPLE, (1,))
extra_tuple = self.tag_v2.get(EXTRASAMPLES, ())
Expand Down
4 changes: 2 additions & 2 deletions src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
#include <math.h>

/* Configuration stuff. Feel free to undef things you don't need. */
#define WITH_IMAGECHOPS /* ImageChops support */
#define WITH_IMAGEDRAW /* ImageDraw support */
#define WITH_IMAGECHOPS /* ImageChops support */
#define WITH_IMAGEDRAW /* ImageDraw support */
// XXX hack202406 disable unmodified code path
// #define WITH_MAPPING /* use memory mapping to read some file formats */
#define WITH_IMAGEPATH /* ImagePath stuff */
Expand Down
1 change: 1 addition & 0 deletions src/libImaging/Imaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef struct ImagingPaletteInstance *ImagingPalette;
#define IMAGING_TYPE_INT32 1
#define IMAGING_TYPE_FLOAT32 2
#define IMAGING_TYPE_SPECIAL 3 /* check mode for details */
#define IMAGING_TYPE_MB 4 /* multi-band format */

#define IMAGING_MODE_LENGTH \
6 + 1 /* Band names ("1", "L", "P", "RGB", "RGBA", "CMYK", "YCbCr", "BGR;xy") */
Expand Down

0 comments on commit 4a80ba9

Please sign in to comment.