Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fresh_images/transformer.ts>crop

Fresh plugin for manipulating images on-the-fly.
Latest
function crop
import { crop } from "https://deno.land/x/fresh_images@v0.3.0/transformer.ts";

Crop an image to a specified area.

Examples

Example 1

import { defineConfig } from "$fresh/server.ts";
import ImagesPlugin from "fresh_images/mod.ts";
import { crop } from "fresh_images/transformer.ts";

export default defineConfig({
 plugins: [
   ImagesPlugin({
     publicPath: "/img",
     transformers: { crop },
   }),
 ],
});

Example 2

<img src="/img/meow.jpg?fn=crop&cx=100&cy=100&cw=100&ch=100" alt="Cropped to 100px by 100px starting at 100px by 100px" />

Parameters

img: Image | GIF

Image to crop

req: Request

URL request containing transformation parameters

Returns

Promise<Image | GIF>

Cropped image