Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

fix(tiktok): pre-check image sizes on TikTok Business channels

Gilad Resisia15f6ea3023b
diff --git a/libraries/nestjs-libraries/src/integrations/social/tiktok.business.provider.ts b/libraries/nestjs-libraries/src/integrations/social/tiktok.business.provider.ts
index 33a48c931..437030dc9 100644
--- a/libraries/nestjs-libraries/src/integrations/social/tiktok.business.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/tiktok.business.provider.ts
@@ -90,6 +90,22 @@ export class TiktokBusinessProvider
if ((firstItems?.length ?? 0) > 35) {
return 'You can select up to 35 pictures';
}
+
+ // TikTok fails the whole photo post when a single image is oversized, and
+ // the status only says `picture_size_check_failed` without naming it.
+ if (firstItems?.every((p) => (p?.path?.indexOf?.('mp4') ?? -1) === -1)) {
+ const dimensions = await Promise.all(
+ firstItems?.map((p) => this.getImageDimensions(p?.path)) ?? []
+ );
+ const tooBig = dimensions.findIndex(
+ (p) => Math.min(p?.width ?? 0, p?.height ?? 0) > 1080
+ );
+ if (tooBig > -1) {
+ return `Image ${tooBig + 1} is ${dimensions[tooBig]?.width}x${
+ dimensions[tooBig]?.height
+ }, TikTok allows a maximum of 1080px on the shorter side`;
+ }
+ }
return true;
}
@@ -221,7 +237,7 @@ export class TiktokBusinessProvider
return {
type: 'bad-body' as const,
value:
- 'Video must be at least 360p, Picture must not exceed 1080x1920',
+ 'Media size not supported by TikTok: images up to 1080px on the shorter side, videos at least 360px on both sides',
};
}