Fix Bluesky image ratios
Some checks failed
Deploy / deploy-frontend (push) Has been cancelled
Deploy / deploy-backend (push) Has been cancelled

This commit is contained in:
Matt Isenhower 2024-11-30 10:03:20 -05:00
parent 73aadd0c0a
commit 3d6ac63152

View File

@ -36,13 +36,16 @@ class BlueskyClient
let images = await Promise.all(
status.media.map(async m => {
// We have to convert the PNG to a JPG for Bluesky because of size limits
let jpeg = await sharp(m.file).jpeg().toBuffer();
let jpeg = sharp(m.file).jpeg();
let metadata = await jpeg.metadata();
let buffer = await jpeg.toBuffer();
let response = await this.#agent.uploadBlob(jpeg, { encoding: 'image/jpeg' });
let response = await this.#agent.uploadBlob(buffer, { encoding: 'image/jpeg' });
return {
image: response.data.blob,
alt: m.altText || '',
aspectRatio: { width: metadata.width, height: metadata.height },
};
}),
);