From a4507dff8e8798db6fa4ba0240b6316c0bdd5071 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 26 Jun 2025 11:48:05 +0300 Subject: [PATCH] fix aspect ratio error --- src/lib/api/index.ts | 14 ++++++++++---- src/view/com/composer/videos/pickVideo.ts | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 7621fbb4cc..5136e6cc8e 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -333,15 +333,21 @@ async function resolveMedia( return {lang: caption.lang, file: data.blob} }), ) + + // lexicon numbers must be floats + const width = Math.round(videoDraft.asset.width) + const height = Math.round(videoDraft.asset.height) + + // aspect ratio values must be >0 - better to leave as unset otherwise + // posting will fail if aspect ratio is set to 0 + const aspectRatio = width > 0 && height > 0 ? {width, height} : undefined + return { $type: 'app.bsky.embed.video', video: videoDraft.pendingPublish.blobRef, alt: videoDraft.altText || undefined, captions: captions.length === 0 ? undefined : captions, - aspectRatio: { - width: videoDraft.asset.width, - height: videoDraft.asset.height, - }, + aspectRatio, } } if (embedDraft.media?.type === 'gif') { diff --git a/src/view/com/composer/videos/pickVideo.ts b/src/view/com/composer/videos/pickVideo.ts index 13bb96805d..a55b69c1d8 100644 --- a/src/view/com/composer/videos/pickVideo.ts +++ b/src/view/com/composer/videos/pickVideo.ts @@ -1,5 +1,5 @@ import { - ImagePickerAsset, + type ImagePickerAsset, launchImageLibraryAsync, UIImagePickerPreferredAssetRepresentationMode, } from 'expo-image-picker'