Generated Computers
Locals: an Apple Silicon engine that runs local LLMs up to 3x faster. A product of Generated Computers.
翻译准备中
个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证制作者的介绍仅有上面的一句话。 更多详情请阅读仓库 README。 仓库 README ↗
正在加载完整 README。
查看完整 README ↗Library that adds a sticker effect to images with transparent backgrounds.
Tested with .png, .webp and .jpg.
It uses HTML Canvas, so it only works in the browser (and not in Node.js).
<script src="https://unpkg.com/@devadri/create-sticker@1/bundle.iife.js"></script>
npm install @devadri/create-sticker
<script src="https://unpkg.com/@devadri/create-sticker@1/bundle.iife.js"></script>
<script>
async function modifyImage(img) {
const options = {
strokeWidth: 20,
strokeColor: "black",
fillHoles: true
}
const stickerImgSrc = await CreateSticker.createSticker(img.src, options);
img.src = stickerImgSrc;
}
</script>
import { createSticker, CreateStickerOptions } from '@devadri/create-sticker';
async function modifyImage(img) {
const options: CreateStickerOptions = {
strokeWidth: 20,
strokeColor: "black",
fillHoles: true
}
const stickerImgSrc = await createSticker(img.src, options);
img.src = stickerImgSrc;
}
| Function | Returns |
|---|---|
createSticker(image, options?) | Promise<string>: data URL |
createStickerBlob(image, options?) | Promise<Blob> |
createStickerCanvas(image, options?) | Promise<HTMLCanvasElement> |
image can be an image URL, a Blob/File, an HTMLImageElement, an HTMLCanvasElement, an OffscreenCanvas or an ImageBitmap.
All options are optional.
| Option | Default | Description |
|---|---|---|
strokeWidth | 20 | Stroke width in pixels. |
strokeColor | "white" | Stroke color (any CSS color). |
fillHoles | true | Fill transparent holes with the stroke color. |
strokeHoles | false | When fillHoles is false, also add the stroke around holes. |
outlines | [] | Extra outlines around the stroke, e.g. [{ width: 3, color: "#999" }]. |
shadow | false | Drop shadow. true or { color, blur, offsetX, offsetY }. |
padding | strokeWidth / 2 | Transparent space added around the image, in pixels. |
trim | false | Crop the result to its visible content. |
maxSize | none | Scale down images larger than this (in pixels) before processing. |
alphaThreshold | 0 | Ignore pixels with alpha (0-255) at or below this value when finding outlines. |
crossOrigin | "anonymous" | CORS mode for image URLs. Remote images must allow CORS. |
outputType | "image/png" | Output format, e.g. "image/webp". |
outputQuality | 1 | Quality (0 to 1) for lossy formats. |
The original code comes from this Stack Overflow answer by markE. Adrián Bueno took that code, rewrote it in TypeScript and prepared it for publishing. The latest improvements were made with Claude Code.