Portive Client
The resize API helps with resizing images while maintaining the correct aspect ratio.
function resizeIn(
size: { width: number; height: number }, // original image size
bounds: { width: number; height: number } // bounding box
): { width: number; height: number } // image size in bounding box
Takes the original size of an image and a bounds size and returns a new size of the image constrained to within the bounds.
import { resizeIn } from "@portive/client/resize"
const newSize = resizeIn(
{ width: 1000, height: 800 },
{ width: 100, height: 100 }
)
// => { width: 100, height: 80 }