Skip to content

Commit

Permalink
chore: fix type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 18, 2023
1 parent 1017deb commit 3a2d92d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/handlers/utils.ts
@@ -1,6 +1,7 @@
import destr from "destr";
import type { Sharp } from "sharp";
import type { Handler, HandlerContext, ImageMeta } from "../types";
import type { ImageMeta } from "image-meta";
import type { Handler, HandlerContext } from "../types";
import * as Handlers from "./handlers";

export function VArg(argument: string) {
Expand Down Expand Up @@ -40,11 +41,11 @@ export function clampDimensionsPreservingAspectRatio(
) {
const desiredAspectRatio = desiredDimensions.width / desiredDimensions.height;
let { width, height } = desiredDimensions;
if (width > sourceDimensions.width) {
if (sourceDimensions.width && width > sourceDimensions.width) {
width = sourceDimensions.width;
height = Math.round(sourceDimensions.width / desiredAspectRatio);
}
if (height > sourceDimensions.height) {
if (sourceDimensions.height && height > sourceDimensions.height) {
height = sourceDimensions.height;
width = Math.round(sourceDimensions.height * desiredAspectRatio);
}
Expand Down

0 comments on commit 3a2d92d

Please sign in to comment.