-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
Possible bug
Are you using the latest version of sharp?
yes, sharp 0.32.3
What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?
System:
OS: Windows 10 10.0.19045
CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
Memory: 6.62 GB / 15.36 GB
Binaries:
Node: 14.21.3 - C:\Program Files\nodejs\node.EXE
npm: 6.14.18 - C:\Program Files\nodejs\npm.CMD
pnpm: 7.17.0 - ~\AppData\Roaming\npm\pnpm.CMD
npmPackages:
sharp: ^0.32.1 => 0.32.3
What are the steps to reproduce?
install sharp 0.32.3
install canvas 2.11.2
What is the expected behaviour?
Overlay text and canvas images on a basemap
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
import { createCanvas} from 'canvas';
import sharp from 'sharp';
const basePicture='./test.png'
const textArray = [
{
input: {
text: {
font: 'OPPOSans',
fontfile: './assets/font/OPPOSans-R.ttf',
align: 'right',
text: `<span foreground='#333999' size='150'>text words</span>`,
rgba: true,
width: 600,
height: 60,
},
},
top: 462,
left: 220,
},
],
const textBuffer=sharp(basePicture).composite(textArray).withMetadata().toBuffer();
const canvas = createCanvas(100, 100);
const context = canvas.getContext('2d');
const width = canvas.width / 2;
const height = canvas.height / 2;
const borderWidth = 3;
context.lineWidth = borderWidth;
context.strokeStyle = SEAL_COLOR;
context.beginPath();
context.arc(width, height, width - borderWidth, 0, Math.PI * 2);
context.shadowColor = SEAL_COLOR;
context.shadowBlur = 1.3;
context.stroke();
context.rotate(0);
context.globalCompositeOperation = 'destination-out';
const canvasBuffer=canvas.toBuffer()
const imageArray = [
{
input:textBuffer,
top: 200,
left: 72,
},
{
input:canvasBuffer,
top: 300,
left: 72,
},
],
sharp(basePicture).composite(imageArray).withMetadata().toBuffer()
Please provide sample image(s) that help explain this problem
verion 0.32.3 0.32.2 0.32.1 0.32.0 have this problem
If I only overlay text on the basemap, there is no problem.
const imageArray = [
{
input:textBuffer,
top: 200,
left: 72,
},
],
If I only overlay canvas on the basemap, there is no problem.
const imageArray = [
{
input:canvasBuffer,
top: 300,
left: 72,
},
],
If I overlay both text and canvas on the basemap, it shows error below.
const imageArray = [
{
input:textBuffer,
top: 200,
left: 72,
},
{
input:canvasBuffer,
top: 300,
left: 72,
},
],
Looks like text overlay and image overlay repeated register PangoFontMap
(process:19072): GLib-GObject-CRITICAL **: 14:41:14.016: **cannot register existing type 'PangoFontMap'**
(process:19072): GLib-GObject-CRITICAL **: 14:41:14.017: cannot add private field to invalid (non-instant
(process:19072): GLib-GObject-CRITICAL **: 14:41:14.017: cannot register existing type 'GListModel'
(process:19072): GLib-GObject-CRITICAL **: 14:41:14.017: g_type_interface_add_prerequisite: assertion 'G_
(process:19072): GLib-CRITICAL **: 14:41:14.017: g_once_init_leave: assertion 'result != 0' failed
(process:19072): GLib-GObject-CRITICAL **: 14:41:14.018: g_type_add_interface_static: assertion 'G_TYPE_I
(process:19072): GLib-CRITICAL **: 14:41:14.018: g_once_init_leave: assertion 'result != 0' failed
(process:19072): GLib-GObject-CRITICAL **: 14:41:14.018: g_type_register_static: assertion 'parent_type >
(process:19072): GLib-CRITICAL **: 14:41:14.018: g_once_init_leave: assertion 'result != 0' failed
(process:19072): GLib-GObject-CRITICAL **: 14:41:14.019: g_type_register_static: assertion 'parent_type >
(process:19072): GLib-GObject-CRITICAL **: 14:41:14.019: cannot register existing type 'PangoCairoFontMap