Skip to content

Commit

Permalink
fix: more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
qilip committed Nov 15, 2023
1 parent 34c23a3 commit 6444a61
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
S3Client,
} from '@aws-sdk/client-s3';
import { randomBytes } from 'crypto';
import fs from 'fs';
import { fromBuffer } from 'pdf2pic';
import sharp from 'sharp';

Expand Down Expand Up @@ -81,13 +82,18 @@ const pdfThumbnail = async (byteArray) => {
height,
};

const storeAsImage = fromBuffer(buffer, options);
const convert = fromBuffer(buffer, options);
const pageToConvertAsImage = 1;

await storeAsImage(pageToConvertAsImage, {
responseType: 'image',
convert(pageToConvertAsImage, { responseType: 'image' }).then((resolve) => {
console.log('Page 1 is now converted as image');
return resolve;
});

if (!fs.existsSync(`/tmp/${tempFileName}.1.png`)) {
throw new Error('Image file not found');
}

const thumbnail = await sharp(`/tmp/${tempFileName}.1.png`)
.resize({
width: 1440 > width ? width : 1440,
Expand Down

0 comments on commit 6444a61

Please sign in to comment.