overlayWith raw input: memory area too small
See original GitHub issueHello,
node version: v7.4.0 ImageMagick version 6.9.6-8 Q16 x86_64 2016-12-12
I am doing images compositions and sometime I am getting this error: Error: VipsImage: memory area too small Error: VipsImage: memory area too small — should be 8000000 bytes, you passed 5262436
According to what I read on issues this is related to the raw option object given to sharp for overlayWith.
What am I doing?
base {
"name": "38db6773-da81-402f-b457-b609e8966147-border.png",
"path": "/tmp/38db6773-da81-402f-b457-b609e8966147-border.png",
"dimensions": {
"width": 2048,
"height": 3591,
"type": "png"
},
"options": {
"raw": {
"channels": 4,
"width": 2048,
"height": 3591
}
},
"gravity": {
"gravity": 0
}
}
other ressource [
{
"name": "66b9f2dd-1b6b-48e1-b7b6-8b010b37ef97-qr.png",
"path": "/tmp/66b9f2dd-1b6b-48e1-b7b6-8b010b37ef97-qr.png",
"dimensions": {
"width": 1147,
"height": 1147,
"type": "png"
},
"options": {
"raw": {
"channels": 4,
"width": 1147,
"height": 1147
}
},
"gravity": {
"gravity": 0
}
},
{
"name": "e29eca8c-01e2-4302-9b33-c59478826cf9-label.png",
"path": "/tmp/e29eca8c-01e2-4302-9b33-c59478826cf9-label.png",
"dimensions": {
"width": 2000,
"height": 1000,
"type": "png"
},
"options": {
"raw": {
"channels": 4,
"width": 2000,
"height": 1000
}
},
"gravity": {
"gravity": 3
}
}
]
Base is the first ressource (the bigger one), and other ressources are the ressource I want to merge into it.
My composition:
const composite = filesShifted.reduce((image: any, overlay: any) => {
return image.then((raw: any) => {
return sharp(raw, overlay.options).overlayWith(overlay.path, overlay.gravity).raw().toBuffer()
})
}, base)
I already had this error in another case and I managed to sort it out, while giving the bigger raw overlay.options for all of my ressource (meaning I was using only the overlay.options from the base for all ressources). However I supposed this is not the right way, and I supposed I had the chance that the allocated memory was enough for all of my ressources, but actually the raw options was innapropriate.
The right thing would be to iterate over my ressource and give the associated options. Actually this is what I am trying to do, but it does not work there. I get the vips error. Do you have an idea about how I can fix this?
Thanks in advance
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
If you’re calling
overlayWith
multiple as part of a reduction, the dimensions passed to the constructor need to always be those of the base image.The output dimensions of a base image overlaid with a second image will be the same as the base image.
Ok got it ! Thanks you so much for your help and Sharp. 👍