Skip to content

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

fix(tiktok): correct picture_size_check_failed message and pre-check image sizes

Gilad Resisi96e46cfec08a
diff --git a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
index c1eb7c323..bdcae267e 100644
--- a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
@@ -67,6 +67,22 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
) {
return 'You need one media';
}
+
+ // 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;
}
@@ -255,7 +271,8 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
if (body.indexOf('picture_size_check_failed') > -1) {
return {
type: 'bad-body' as const,
- value: 'Video must be at least 720p, Picture must no exceed 1080p',
+ value:
+ 'Media size not supported by TikTok: images up to 1080px on the shorter side, videos at least 360px on both sides',
};
}