aboutsummaryrefslogtreecommitdiff
path: root/packages/integrations/image/src/utils/metadata.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/image/src/utils/metadata.ts')
-rw-r--r--packages/integrations/image/src/utils/metadata.ts28
1 files changed, 0 insertions, 28 deletions
diff --git a/packages/integrations/image/src/utils/metadata.ts b/packages/integrations/image/src/utils/metadata.ts
deleted file mode 100644
index 7bb8afa41..000000000
--- a/packages/integrations/image/src/utils/metadata.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import sizeOf from 'image-size';
-import fs from 'node:fs/promises';
-import { fileURLToPath } from 'node:url';
-import type { InputFormat } from '../loaders/index.js';
-import type { ImageMetadata } from '../vite-plugin-astro-image.js';
-
-export interface Metadata extends ImageMetadata {
- orientation?: number;
-}
-
-export async function metadata(src: URL | string, data?: Buffer): Promise<Metadata | undefined> {
- const file = data || (await fs.readFile(src));
- const { width, height, type, orientation } = sizeOf(file);
- const isPortrait = (orientation || 0) >= 5;
-
- if (!width || !height || !type) {
- return undefined;
- }
-
- return {
- // We shouldn't call fileURLToPath function if it starts with /@astroimage/ because it will throw Invalid URL error
- src: typeof src === 'string' && /^[\/\\]?@astroimage/.test(src) ? src : fileURLToPath(src),
- width: isPortrait ? height : width,
- height: isPortrait ? width : height,
- format: type as InputFormat,
- orientation,
- };
-}