有没有办法在不使用 canvas 的情况下合并 JavaScript 中的图像?
Is there a way to merge images in JavaScript without using canvas?
我正在尝试导出大于 the maximum canvas size. I've tiled the canvas export, so that each tile is small enough to be generated (with toBlob) 的图像 (PNG)。现在我需要一种将图像合并在一起的方法,但找不到一种本身不使用 canvas 的方法。这有可能吗?
Kaiido's answer worked great. I'm tiling the canvas export with getImageData (moving the contents of the canvas for each tile), then loop over all ImageData tiles & creating a new 1D array of RGBA values which I send to fast-png 的 encode
。它不是很快,尤其是在移动设备上(一张约 30MP 的图像在 iPhone X 上合并大约需要 40 秒),但我是在后台线程上使用 Worker 进行的。
我正在尝试导出大于 the maximum canvas size. I've tiled the canvas export, so that each tile is small enough to be generated (with toBlob) 的图像 (PNG)。现在我需要一种将图像合并在一起的方法,但找不到一种本身不使用 canvas 的方法。这有可能吗?
Kaiido's answer worked great. I'm tiling the canvas export with getImageData (moving the contents of the canvas for each tile), then loop over all ImageData tiles & creating a new 1D array of RGBA values which I send to fast-png 的 encode
。它不是很快,尤其是在移动设备上(一张约 30MP 的图像在 iPhone X 上合并大约需要 40 秒),但我是在后台线程上使用 Worker 进行的。