Add player bug reports and profile identity features
This commit is contained in:
28
lib/support-images.ts
Normal file
28
lib/support-images.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import sharp from "sharp";
|
||||
import { screenshotLimit } from "../shared/bug-reports";
|
||||
|
||||
export async function supportScreenshot(bytes: Uint8Array) {
|
||||
if (!bytes.length || bytes.length > screenshotLimit)
|
||||
throw new Error("Use a screenshot smaller than 5 MB");
|
||||
const image = sharp(bytes, {
|
||||
limitInputPixels: 24_000_000,
|
||||
failOn: "error",
|
||||
animated: false,
|
||||
});
|
||||
const meta = await image.metadata();
|
||||
if (
|
||||
!["png", "jpeg", "webp"].includes(meta.format ?? "") ||
|
||||
(meta.pages ?? 1) !== 1
|
||||
)
|
||||
throw new Error("Choose a PNG, JPG, or WebP screenshot");
|
||||
return image
|
||||
.rotate()
|
||||
.resize({
|
||||
width: 2400,
|
||||
height: 2400,
|
||||
fit: "inside",
|
||||
withoutEnlargement: true,
|
||||
})
|
||||
.webp({ quality: 85 })
|
||||
.toBuffer();
|
||||
}
|
||||
Reference in New Issue
Block a user