From 41b1437dd39bda88ff432f56f8968c4a054c6a16 Mon Sep 17 00:00:00 2001 From: delucis Date: Fri, 22 Jul 2022 17:14:18 +0200 Subject: [PATCH 1/2] Handle EXIF orientation flag --- packages/integrations/image/src/metadata.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/integrations/image/src/metadata.ts b/packages/integrations/image/src/metadata.ts index 020d9461fdc3..823862ea7938 100644 --- a/packages/integrations/image/src/metadata.ts +++ b/packages/integrations/image/src/metadata.ts @@ -5,7 +5,8 @@ import { ImageMetadata, InputFormat } from './types'; export async function metadata(src: string): Promise { const file = await fs.readFile(src); - const { width, height, type } = await sizeOf(file); + const { width, height, type, orientation } = await sizeOf(file); + const isPortrait = (orientation || 0) >= 5; if (!width || !height || !type) { return undefined; @@ -13,8 +14,8 @@ export async function metadata(src: string): Promise return { src, - width, - height, + width: isPortrait ? height : width, + height: isPortrait ? width : height, format: type as InputFormat, }; } From dd26b26d14faad73b57c1222422f46e73ec5cbb0 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 22 Jul 2022 17:18:24 +0200 Subject: [PATCH 2/2] Create gentle-mails-mate.md --- .changeset/gentle-mails-mate.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/gentle-mails-mate.md diff --git a/.changeset/gentle-mails-mate.md b/.changeset/gentle-mails-mate.md new file mode 100644 index 000000000000..eb3d561f229a --- /dev/null +++ b/.changeset/gentle-mails-mate.md @@ -0,0 +1,5 @@ +--- +"@astrojs/image": patch +--- + +Handle EXIF orientation flag