diff --git a/packages/binding/index.d.ts b/packages/binding/index.d.ts index 83a775e..607db5e 100644 --- a/packages/binding/index.d.ts +++ b/packages/binding/index.d.ts @@ -55,7 +55,7 @@ export const enum ChromaSubsampling { * What if the chroma subsampling model is 4:0:0? * That says to use every pixel of luma data, but that each row has 0 chroma samples applied to it. The resulting image, then, is comprised solely of the luminance data—a greyscale image. */ - Yuv400 = 3, + Yuv400 = 3 } export interface JpegCompressOptions { /** Output quality, default is 100 (lossless) */ @@ -67,11 +67,7 @@ export interface JpegCompressOptions { optimizeScans?: boolean | undefined | null } export function compressJpegSync(input: Buffer, options?: JpegCompressOptions | undefined | null): Buffer -export function compressJpeg( - input: Buffer, - options?: JpegCompressOptions | undefined | null, - signal?: AbortSignal | undefined | null, -): Promise +export function compressJpeg(input: Buffer, options?: JpegCompressOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise export const enum CompressionType { /** Default compression level */ Default = 0, @@ -82,7 +78,7 @@ export const enum CompressionType { /** Huffman coding compression */ Huffman = 3, /** Run-length encoding compression */ - Rle = 4, + Rle = 4 } export const enum FilterType { /** @@ -102,7 +98,7 @@ export const enum FilterType { * Uses a heuristic to select one of the preceding filters for each * scanline rather than one filter for the entire image */ - Adaptive = 5, + Adaptive = 5 } export interface PngEncodeOptions { /** Default is `CompressionType::Default` */ @@ -155,11 +151,7 @@ export interface PNGLosslessOptions { useHeuristics?: boolean | undefined | null } export function losslessCompressPngSync(input: Buffer, options?: PNGLosslessOptions | undefined | null): Buffer -export function losslessCompressPng( - input: Buffer, - options?: PNGLosslessOptions | undefined | null, - signal?: AbortSignal | undefined | null, -): Promise +export function losslessCompressPng(input: Buffer, options?: PNGLosslessOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise export interface PngQuantOptions { /** default is 70 */ minQuality?: number | undefined | null @@ -178,11 +170,7 @@ export interface PngQuantOptions { posterization?: number | undefined | null } export function pngQuantizeSync(input: Buffer, options?: PngQuantOptions | undefined | null): Buffer -export function pngQuantize( - input: Buffer, - options?: PngQuantOptions | undefined | null, - signal?: AbortSignal | undefined | null, -): Promise +export function pngQuantize(input: Buffer, options?: PngQuantOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise export const enum Orientation { /** Normal */ Horizontal = 1, @@ -192,7 +180,7 @@ export const enum Orientation { MirrorHorizontalAndRotate270Cw = 5, Rotate90Cw = 6, MirrorHorizontalAndRotate90Cw = 7, - Rotate270Cw = 8, + Rotate270Cw = 8 } /** * Available Sampling Filters. @@ -272,7 +260,7 @@ export const enum ResizeFilterType { /** Gaussian Filter */ Gaussian = 3, /** Lanczos with window 3 */ - Lanczos3 = 4, + Lanczos3 = 4 } export const enum JsColorType { /** Pixel is 8-bit luminance */ @@ -294,7 +282,7 @@ export const enum JsColorType { /** Pixel is 32-bit float RGB */ Rgb32F = 8, /** Pixel is 32-bit float RGBA */ - Rgba32F = 9, + Rgba32F = 9 } export interface Metadata { width: number @@ -362,6 +350,8 @@ export class Transformer { * just like the css webkit filter hue-rotate(180) */ huerotate(hue: number): this + /** Crop a cut-out of this image delimited by the bounding rectangle. */ + crop(x: number, y: number, width: number, height: number): this /** * The quality factor `quality_factor` ranges from 0 to 100 and controls the loss and quality during compression. * The value 0 corresponds to low quality and small output sizes, whereas 100 is the highest quality and largest output size. diff --git a/website/.gitignore b/website/.gitignore index 26f437d..cf64bf6 100644 --- a/website/.gitignore +++ b/website/.gitignore @@ -3,3 +3,4 @@ public/img/example.mjs public/img/sharp.mjs public/img/*.manipulated.webp +public/img/og.png \ No newline at end of file diff --git a/website/generate-img.js b/website/generate-img.js index 782cf7b..c112bcf 100644 --- a/website/generate-img.js +++ b/website/generate-img.js @@ -14,6 +14,7 @@ await fs.writeFile('public/img/sharp.mjs', await fs.readFile('../sharp.mjs')) if (process.env.VERCEL) { const gnuBinary = await fetch(`https://unpkg.com/@napi-rs/image-linux-x64-gnu`, { + redirect: 'follow', follow: 10, }).then((res) => res.arrayBuffer()) console.info(chalk.greenBright(`Installed @napi-rs/image.linux-x64-gnu, size: ${gnuBinary.byteLength}`)) @@ -34,3 +35,8 @@ execSync('node manipulate.mjs', { cwd: __dirname, stdio: 'inherit', }) + +execSync(`node og-image`, { + cwd: join(__dirname, '..', '..'), + stdio: 'inherit', +}) diff --git a/website/nextra.config.js b/website/nextra.config.js index 7f8f731..908fe4f 100644 --- a/website/nextra.config.js +++ b/website/nextra.config.js @@ -29,10 +29,13 @@ export default { ) }, - head: ({ meta }) => { + head: ({ title, meta }) => { return ( <> {/* Favicons, meta */} + + + @@ -40,6 +43,12 @@ export default { + + + + + +