an image source can be an HTMLImageElement
, HTMLCanvasElement
, ImageBitmap
, etc..
Optional
width: numberOptional
crop_rect: Rectdimension of the cropping rectangle. leave as undefined
if you wish not to crop, or only provide a partial Rect
Optional
bitmap_options: ImageBitmapOptionsOptional
image_data_options: ImageDataSettings
extract the ImageData from an image source (of type CanvasImageSource), with optional cropping.
due to the fact that this function utilizes a
canvas
, it is important to note that the outputImageData
is sometimes lossy in nature, because gpu-accelerated web-browsers approximate the colors, and also due to rounding errors from/to internal float-valued colors and output integer-valued colors.but generally speaking, the
ImageData
can be lossless if all of the following are satisfied:flags
pageimg_src
has either no alpha-channel, or 100% visible alpha-channel throughout (ie non-transparent image)