-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to overlayWith new sharp() then how to overlayWith text? #1263
Comments
Hello, the API in #512 (comment) is proposed. Please see #512 for suggestions of using SVG as an alternative and subscribe to it for updates. |
@lovell const titlebar = new Buffer.from(
`<svg width="1366" height="768">
<style>
@font-face {
font-family: Aller_Light;
src: url(${Aller_Light_Path}) format('truetype');
}
</style>
<rect x="0" y="0" width="1366" height="768" fill="#000" fill-opacity="0.4"/>
<rect x="0" y="0" width="1366" height="96" fill="#000" fill-opacity="0.8"/>
<text class="title" style="font-size: 24; font-family:Aller_Light" x="5" y="22" fill="#FFF">
Hello World
</text>
</svg>`
);
sharp(Buffer.concat(imgArrayBuffer))
.toFormat('jpeg')
.overlayWith(titlebar)
.toFile(recpath)
.then(buf => {
console.log(`[sharpOK]success!`);
})
.catch(err => {
console.log(`[sharpErr]${err}`);
}); I get this error: How can I successfully load the font? |
Please see #1162 |
@lovell |
I find your sample code like this in #512 , but it do not work.
There is no
text
parameter here, it doesn't even exist in the API documentationAnd then i find another sample code in #470 , there is no
create
parameter in overlayWith.But i can find the
options.create
in your API documentationSo, did I use the wrong version, or did these features have not yet been developed?
Is there another alternative here? I just want to add a layer of translucent foreground color to the picture and print some text on it.
The text was updated successfully, but these errors were encountered: