Skip to content

Commit

Permalink
Replaced tuple args with mode string where equivalent
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Nov 13, 2024
1 parent 48c7eb2 commit 871963b
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/PIL/BlpImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def _open(self) -> None:
raise BLPFormatError(msg)

self._mode = "RGBA" if self._blp_alpha_depth else "RGB"
self.tile = [ImageFile._Tile(decoder, (0, 0) + self.size, 0, (self.mode, 0, 1))]
self.tile = [ImageFile._Tile(decoder, (0, 0) + self.size, 0, self.mode)]


class _BLPBaseDecoder(ImageFile.PyDecoder):
Expand Down
4 changes: 1 addition & 3 deletions src/PIL/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
+ struct.pack("<4I", *rgba_mask) # dwRGBABitMask
+ struct.pack("<5I", DDSCAPS.TEXTURE, 0, 0, 0, 0)
)
ImageFile._save(
im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 0, (rawmode, 0, 1))]
)
ImageFile._save(im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 0, rawmode)])


def _accept(prefix: bytes) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/FpxImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _open_subimage(self, index: int = 1, subimage: int = 0) -> None:
"raw",
(x, y, x1, y1),
i32(s, i) + 28,
(self.rawmode,),
self.rawmode,
)
)

Expand Down
2 changes: 1 addition & 1 deletion src/PIL/FtexImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _open(self) -> None:
self._mode = "RGBA"
self.tile = [ImageFile._Tile("bcn", (0, 0) + self.size, 0, (1,))]
elif format == Format.UNCOMPRESSED:
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 0, ("RGB", 0, 1))]
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 0, "RGB")]
else:
msg = f"Invalid texture compression format: {repr(format)}"
raise ValueError(msg)
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/GdImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _open(self) -> None:
"raw",
(0, 0) + self.size,
7 + true_color_offset + 4 + 256 * 4,
("L", 0, 1),
"L",
)
]

Expand Down
2 changes: 1 addition & 1 deletion src/PIL/ImtImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _open(self) -> None:
"raw",
(0, 0) + self.size,
self.fp.tell() - len(buffer),
(self.mode, 0, 1),
self.mode,
)
]

Expand Down
4 changes: 2 additions & 2 deletions src/PIL/MspImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _open(self) -> None:
self._size = i16(s, 4), i16(s, 6)

if s[:4] == b"DanM":
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 32, ("1", 0, 1))]
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 32, "1")]
else:
self.tile = [ImageFile._Tile("MSP", (0, 0) + self.size, 32)]

Expand Down Expand Up @@ -188,7 +188,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
fp.write(o16(h))

# image body
ImageFile._save(im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 32, ("1", 0, 1))])
ImageFile._save(im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 32, "1")])


#
Expand Down
4 changes: 1 addition & 3 deletions src/PIL/PixarImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ def _open(self) -> None:
# FIXME: to be continued...

# create tile descriptor (assuming "dumped")
self.tile = [
ImageFile._Tile("raw", (0, 0) + self.size, 1024, (self.mode, 0, 1))
]
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 1024, self.mode)]


#
Expand Down
8 changes: 2 additions & 6 deletions src/PIL/SpiderImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ def _open(self) -> None:
self.rawmode = "F;32F"
self._mode = "F"

self.tile = [
ImageFile._Tile("raw", (0, 0) + self.size, offset, (self.rawmode, 0, 1))
]
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, offset, self.rawmode)]
self._fp = self.fp # FIXME: hack

@property
Expand Down Expand Up @@ -280,9 +278,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
fp.writelines(hdr)

rawmode = "F;32NF" # 32-bit native floating point
ImageFile._save(
im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 0, (rawmode, 0, 1))]
)
ImageFile._save(im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 0, rawmode)])


def _save_spider(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
Expand Down
4 changes: 1 addition & 3 deletions src/PIL/XVThumbImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ def _open(self) -> None:
self.palette = ImagePalette.raw("RGB", PALETTE)

self.tile = [
ImageFile._Tile(
"raw", (0, 0) + self.size, self.fp.tell(), (self.mode, 0, 1)
)
ImageFile._Tile("raw", (0, 0) + self.size, self.fp.tell(), self.mode)
]


Expand Down
4 changes: 1 addition & 3 deletions src/PIL/XpmImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ def _open(self) -> None:
self._mode = "P"
self.palette = ImagePalette.raw("RGB", b"".join(palette))

self.tile = [
ImageFile._Tile("raw", (0, 0) + self.size, self.fp.tell(), ("P", 0, 1))
]
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, self.fp.tell(), "P")]

def load_read(self, read_bytes: int) -> bytes:
#
Expand Down

0 comments on commit 871963b

Please sign in to comment.