scaleHelper.tsx 412 Bytes
Newer Older
Nikhila Ravi's avatar
Nikhila Ravi committed
1
2
3
4
5
6
7
8
9
10
11
12

// Helper function for handling image scaling needed for SAM
const handleImageScale = (image: HTMLImageElement) => {
  // Input images to SAM must be resized so the longest side is 1024
  const LONG_SIDE_LENGTH = 1024;
  let w = image.naturalWidth;
  let h = image.naturalHeight;
  const samScale = LONG_SIDE_LENGTH / Math.max(h, w);
  return { height: h, width: w, samScale };
};

export { handleImageScale };