This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import imageCompression from 'browser-image-compression';
|
||||
import { PDFDocument } from 'pdf-lib';
|
||||
import { ImageUtils } from '../../../shared/utilities/image-utils';
|
||||
|
||||
/**
|
||||
* Builds a single merged PDF from a list of paper-proof attachments (mostly phone photos).
|
||||
@@ -12,11 +12,6 @@ import { PDFDocument } from 'pdf-lib';
|
||||
* All work happens client-side; the resulting Blob is uploaded as the session's proof.pdf.
|
||||
*/
|
||||
|
||||
// Tunables — adjust if proofs look too soft (raise) or files are too large (lower).
|
||||
const MAX_EDGE_PX = 2000; // longest image edge after compression
|
||||
const JPEG_QUALITY = 0.72; // 0..1
|
||||
const MAX_SIZE_MB = 1; // target ceiling per image
|
||||
|
||||
// US Letter, in PDF points (72pt = 1in).
|
||||
const PAGE_W = 612;
|
||||
const PAGE_H = 792;
|
||||
@@ -42,13 +37,7 @@ export async function buildProofPdf(files: File[]): Promise<ProofBuildResult> {
|
||||
}
|
||||
|
||||
if (file.type.startsWith('image/')) {
|
||||
const compressed = await imageCompression(file, {
|
||||
maxWidthOrHeight: MAX_EDGE_PX,
|
||||
maxSizeMB: MAX_SIZE_MB,
|
||||
initialQuality: JPEG_QUALITY,
|
||||
fileType: 'image/jpeg',
|
||||
useWebWorker: true,
|
||||
});
|
||||
const compressed = await ImageUtils.compressForUpload(file);
|
||||
const jpgBytes = new Uint8Array(await compressed.arrayBuffer());
|
||||
const img = await doc.embedJpg(jpgBytes);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user