Open swissspidy opened 4 months ago
Extracting this from #491.
If not explicitly setting canvas.getContext( '2d', { alpha: false }, the resulting image after canvas-based resizing and compression will have an alpha channel.
canvas.getContext( '2d', { alpha: false }
Docs: https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext#alpha
This leads to incorrect has_transparency values as even vips then thinks the image has alpha channels.
has_transparency
Right now I'm doing alpha: [ 'image/png', 'image/webp' ].includes( sourceType ),, which helps for JPEGs, but obviously not PNGs or WebP image.
alpha: [ 'image/png', 'image/webp' ].includes( sourceType ),
I feel like I have to use vips to check transparency already very early, and then pass on the alpha information to the canvas worker.
Extracting this from #491.
If not explicitly setting
canvas.getContext( '2d', { alpha: false }
, the resulting image after canvas-based resizing and compression will have an alpha channel.Docs: https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext#alpha
This leads to incorrect
has_transparency
values as even vips then thinks the image has alpha channels.Right now I'm doing
alpha: [ 'image/png', 'image/webp' ].includes( sourceType ),
, which helps for JPEGs, but obviously not PNGs or WebP image.I feel like I have to use vips to check transparency already very early, and then pass on the alpha information to the canvas worker.