def init_background(self): height = self.get_pixel_height() width = self.get_pixel_width() if self.background_image is not None: raise NotImplementedError('not available in javascript') else: background_rgba = color_to_int_rgba( self.background_color, self.background_opacity ) self.background = np.zeros( (height, width, self.n_channels), dtype=self.pixel_array_dtype ) self.background[:, :] = background_rgba
def init_background(self): height = self.get_pixel_height() width = self.get_pixel_width() if self.background_image is not None: path = get_full_raster_image_path(self.background_image) image = Image.open(path).convert(self.image_mode) # TODO, how to gracefully handle backgrounds # with different sizes? self.background = np.array(image)[:height, :width] self.background = self.background.astype(self.pixel_array_dtype) else: background_rgba = color_to_int_rgba(self.background_color, self.background_opacity) self.background = np.zeros((height, width, self.n_channels), dtype=self.pixel_array_dtype) self.background[:, :] = background_rgba
def init_background(self): height = self.get_pixel_height() width = self.get_pixel_width() if self.background_image is not None: path = get_full_raster_image_path(self.background_image) image = Image.open(path).convert(self.image_mode) # TODO, how to gracefully handle backgrounds # with different sizes? self.background = np.array(image)[:height, :width] self.background = self.background.astype(self.pixel_array_dtype) else: background_rgba = color_to_int_rgba( self.background_color, self.background_opacity ) self.background = np.zeros( (height, width, self.n_channels), dtype=self.pixel_array_dtype ) self.background[:, :] = background_rgba