def blend_on_canvas(img, width, height, bgcolor=u'#ffffff'):
 (w, h) = (img.width(), img.height())
 (scaled, nw, nh) = fit_image(w, h, width, height)
 if scaled:
  img = img.scaled(nw, nh, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
  (w, h) = (nw, nh)
 canvas = QImage(width, height, QImage.Format_RGB32)
 canvas.fill(QColor(bgcolor))
 overlay_image(img, canvas, ((width - w) // 2), ((height - h) // 2))
 return canvas

def blend_on_canvas ( img , width , height , bgcolor = u'#ffffff' ) : ( w , h ) = ( img . width ( ) , img . height ( ) ) ( scaled , nw , nh ) = fit_image ( w , h , width , height ) if scaled : img = img . scaled ( nw , nh , Qt . IgnoreAspectRatio , Qt . SmoothTransformation ) ( w , h ) = ( nw , nh ) canvas = QImage ( width , height , QImage . Format_RGB32 ) canvas . fill ( QColor ( bgcolor ) ) overlay_image ( img , canvas , ( ( width - w ) // 2 ) , ( ( height - h ) // 2 ) ) return canvas
blend the img onto a canvas with the specified background color and size .