@@ -375,7 +375,7 @@ def __init__(
375
375
planes = None ,
376
376
colormap = None ,
377
377
maxval = None ,
378
- chunk_limit = 2 ** 20 ,
378
+ chunk_limit = 2 ** 20 ,
379
379
x_pixels_per_unit = None ,
380
380
y_pixels_per_unit = None ,
381
381
unit_is_meter = False ,
@@ -544,7 +544,7 @@ def __init__(
544
544
if width <= 0 or height <= 0 :
545
545
raise ProtocolError ("width and height must be greater than zero" )
546
546
# http://www.w3.org/TR/PNG/#7Integers-and-byte-order
547
- if width > 2 ** 31 - 1 or height > 2 ** 31 - 1 :
547
+ if width > 2 ** 31 - 1 or height > 2 ** 31 - 1 :
548
548
raise ProtocolError ("width and height cannot exceed 2**31-1" )
549
549
550
550
if alpha and transparent is not None :
@@ -918,7 +918,7 @@ def write_chunk(outfile, tag, data=b""):
918
918
outfile .write (data )
919
919
checksum = zlib .crc32 (tag )
920
920
checksum = zlib .crc32 (data , checksum )
921
- checksum &= 2 ** 32 - 1
921
+ checksum &= 2 ** 32 - 1
922
922
outfile .write (struct .pack ("!I" , checksum ))
923
923
924
924
@@ -1548,7 +1548,7 @@ def _bytes_to_values(self, bs, width=None):
1548
1548
# Samples per byte
1549
1549
spb = 8 // self .bitdepth
1550
1550
out = bytearray ()
1551
- mask = 2 ** self .bitdepth - 1
1551
+ mask = 2 ** self .bitdepth - 1
1552
1552
shifts = [self .bitdepth * i for i in reversed (list (range (spb )))]
1553
1553
for o in bs :
1554
1554
out .extend ([mask & (o >> i ) for i in shifts ])
@@ -1632,7 +1632,7 @@ def _chunk_len_type(self):
1632
1632
if len (x ) != 8 :
1633
1633
raise FormatError ("End of file whilst reading chunk length and type." )
1634
1634
length , type = struct .unpack ("!I4s" , x )
1635
- if length > 2 ** 31 - 1 :
1635
+ if length > 2 ** 31 - 1 :
1636
1636
raise FormatError ("Chunk %s is too large: %d." % (type , length ))
1637
1637
# Check that all bytes are in valid ASCII range.
1638
1638
# https://www.w3.org/TR/2003/REC-PNG-20031110/#5Chunk-layout
@@ -1722,7 +1722,7 @@ def _process_PLTE(self, data):
1722
1722
self .plte = data
1723
1723
if len (data ) % 3 != 0 :
1724
1724
raise FormatError ("PLTE chunk's length should be a multiple of 3." )
1725
- if len (data ) > (2 ** self .bitdepth ) * 3 :
1725
+ if len (data ) > (2 ** self .bitdepth ) * 3 :
1726
1726
raise FormatError ("PLTE chunk is too long." )
1727
1727
if len (data ) == 0 :
1728
1728
raise FormatError ("Empty PLTE is not allowed." )
@@ -2014,7 +2014,7 @@ def _as_rescale(self, get, targetbitdepth):
2014
2014
2015
2015
width , height , pixels , info = get ()
2016
2016
maxval = 2 ** info ["bitdepth" ] - 1
2017
- targetmaxval = 2 ** targetbitdepth - 1
2017
+ targetmaxval = 2 ** targetbitdepth - 1
2018
2018
factor = float (targetmaxval ) / float (maxval )
2019
2019
info ["bitdepth" ] = targetbitdepth
2020
2020
0 commit comments