@@ -933,9 +933,9 @@ def convert(
933933 msg = "illegal conversion"
934934 raise ValueError (msg )
935935 im = self .im .convert_matrix (mode , matrix )
936- new = self ._new (im )
936+ new_im = self ._new (im )
937937 if has_transparency and self .im .bands == 3 :
938- transparency = new .info ["transparency" ]
938+ transparency = new_im .info ["transparency" ]
939939
940940 def convert_transparency (m , v ):
941941 v = m [0 ] * v [0 ] + m [1 ] * v [1 ] + m [2 ] * v [2 ] + m [3 ] * 0.5
@@ -948,8 +948,8 @@ def convert_transparency(m, v):
948948 convert_transparency (matrix [i * 4 : i * 4 + 4 ], transparency )
949949 for i in range (0 , len (transparency ))
950950 )
951- new .info ["transparency" ] = transparency
952- return new
951+ new_im .info ["transparency" ] = transparency
952+ return new_im
953953
954954 if mode == "P" and self .mode == "RGBA" :
955955 return self .quantize (colors )
@@ -980,7 +980,7 @@ def convert_transparency(m, v):
980980 else :
981981 # get the new transparency color.
982982 # use existing conversions
983- trns_im = Image (). _new ( core . new (self .mode , (1 , 1 ) ))
983+ trns_im = new (self .mode , (1 , 1 ))
984984 if self .mode == "P" :
985985 trns_im .putpalette (self .palette )
986986 if isinstance (t , tuple ):
@@ -1021,23 +1021,25 @@ def convert_transparency(m, v):
10211021
10221022 if mode == "P" and palette == Palette .ADAPTIVE :
10231023 im = self .im .quantize (colors )
1024- new = self ._new (im )
1024+ new_im = self ._new (im )
10251025 from . import ImagePalette
10261026
1027- new .palette = ImagePalette .ImagePalette ("RGB" , new .im .getpalette ("RGB" ))
1027+ new_im .palette = ImagePalette .ImagePalette (
1028+ "RGB" , new_im .im .getpalette ("RGB" )
1029+ )
10281030 if delete_trns :
10291031 # This could possibly happen if we requantize to fewer colors.
10301032 # The transparency would be totally off in that case.
1031- del new .info ["transparency" ]
1033+ del new_im .info ["transparency" ]
10321034 if trns is not None :
10331035 try :
1034- new .info ["transparency" ] = new .palette .getcolor (trns , new )
1036+ new_im .info ["transparency" ] = new_im .palette .getcolor (trns , new_im )
10351037 except Exception :
10361038 # if we can't make a transparent color, don't leave the old
10371039 # transparency hanging around to mess us up.
1038- del new .info ["transparency" ]
1040+ del new_im .info ["transparency" ]
10391041 warnings .warn ("Couldn't allocate palette entry for transparency" )
1040- return new
1042+ return new_im
10411043
10421044 if "LAB" in (self .mode , mode ):
10431045 other_mode = mode if self .mode == "LAB" else self .mode
0 commit comments