@@ -553,17 +553,25 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
553553 if A .ndim == 2 : # _interpolation_stage == 'rgba'
554554 self .norm .autoscale_None (A )
555555 A = self .to_rgba (A )
556- alpha = self ._get_scalar_alpha ()
557- if A .shape [2 ] == 3 :
558- # No need to resample alpha or make a full array; NumPy will expand
559- # this out and cast to uint8 if necessary when it's assigned to the
560- # alpha channel below.
561- output_alpha = (255 * alpha ) if A .dtype == np .uint8 else alpha
556+
557+ alpha = self .get_alpha ()
558+ if alpha is not None and np .ndim (alpha ) > 0 :
559+ output_alpha = _resample (self , alpha , out_shape , t , resample = True )
560+ output = _resample ( # resample rgb channels
561+ # alpha: float, should only be specified when alpha is a scalar
562+ self , _rgb_to_rgba (A [..., :3 ]), out_shape , t )
562563 else :
563- output_alpha = _resample ( # resample alpha channel
564- self , A [..., 3 ], out_shape , t , alpha = alpha )
565- output = _resample ( # resample rgb channels
566- self , _rgb_to_rgba (A [..., :3 ]), out_shape , t , alpha = alpha )
564+ alpha = self ._get_scalar_alpha ()
565+ if A .shape [2 ] == 3 :
566+ # No need to resample alpha or make a full array; NumPy will
567+ # expand this out and cast to uint8 if necessary when it's
568+ # assigned to the alpha channel below.
569+ output_alpha = (255 * alpha ) if A .dtype == np .uint8 else alpha
570+ else :
571+ output_alpha = _resample ( # resample alpha channel
572+ self , A [..., 3 ], out_shape , t , alpha = alpha )
573+ output = _resample ( # resample rgb channels
574+ self , _rgb_to_rgba (A [..., :3 ]), out_shape , t , alpha = alpha )
567575 output [..., 3 ] = output_alpha # recombine rgb and alpha
568576
569577 # output is now either a 2D array of normed (int or float) data
0 commit comments