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

x/fresh_images/transformer.ts>resize

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

Resize an image to a given width and/or height.

Examples

Example 1

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

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

Example 2

<img src="/img/meow.jpg?fn=resize&rw=100" alt="Resized to 100px wide" />
<img src="/img/meow.jpg?fn=resize&resizeWidth=100" alt="Resized to 100px wide" />
<img src="/img/meow.jpg?fn=resize&rh=100" alt="Resized to 100px tall" />
<img src="/img/meow.jpg?fn=resize&resizeHeight=100" alt="Resized to 100px tall" />
<img src="/img/meow.jpg?fn=resize&rw=100&h=100" alt="Resized to 100px by 100px" />
<img src="/img/meow.jpg?fn=resize&resizeWidth=100&resizeHeight=100" alt="Resized to 100px by 100px" />

Parameters

img: Image | GIF

Image to resize

req: Request

URL request containing transformation parameters

Returns

Promise<Image | GIF>

Resized image