Compare commits
2 Commits
one-pass-p
...
rotation-o
Author | SHA1 | Date | |
---|---|---|---|
fd98d67b3e | |||
db1db8506e |
@ -20,7 +20,7 @@ import * as browserPDF from './browser-pdf/encoder';
|
|||||||
type ProcessorWorkerApi = import('./processor-worker').ProcessorWorkerApi;
|
type ProcessorWorkerApi = import('./processor-worker').ProcessorWorkerApi;
|
||||||
|
|
||||||
/** How long the worker should be idle before terminating. */
|
/** How long the worker should be idle before terminating. */
|
||||||
const workerTimeout = 1000;
|
const workerTimeout = 10000;
|
||||||
|
|
||||||
interface ProcessingJobOptions {
|
interface ProcessingJobOptions {
|
||||||
needsWorker?: boolean;
|
needsWorker?: boolean;
|
||||||
|
@ -4,10 +4,6 @@ const bpp = 4;
|
|||||||
|
|
||||||
export function rotate(data: ImageData, opts: RotateOptions): ImageData {
|
export function rotate(data: ImageData, opts: RotateOptions): ImageData {
|
||||||
const { rotate } = opts;
|
const { rotate } = opts;
|
||||||
|
|
||||||
// Early exit if there's no transform.
|
|
||||||
if (rotate === 0) return data;
|
|
||||||
|
|
||||||
const flipDimensions = rotate % 180 !== 0;
|
const flipDimensions = rotate % 180 !== 0;
|
||||||
const { width: inputWidth, height: inputHeight } = data;
|
const { width: inputWidth, height: inputHeight } = data;
|
||||||
const outputWidth = flipDimensions ? inputHeight : inputWidth;
|
const outputWidth = flipDimensions ? inputHeight : inputWidth;
|
||||||
|
@ -85,12 +85,18 @@ interface UpdateImageOptions {
|
|||||||
skipPreprocessing?: boolean;
|
skipPreprocessing?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processInput(
|
async function processInput(
|
||||||
data: ImageData,
|
data: ImageData,
|
||||||
inputProcessData: InputProcessorState,
|
inputProcessData: InputProcessorState,
|
||||||
processor: Processor,
|
processor: Processor,
|
||||||
) {
|
) {
|
||||||
return processor.rotate(data, inputProcessData.rotate);
|
let processedData = data;
|
||||||
|
|
||||||
|
if (inputProcessData.rotate.rotate !== 0) {
|
||||||
|
processedData = await processor.rotate(processedData, inputProcessData.rotate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return processedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function preprocessImage(
|
async function preprocessImage(
|
||||||
|
Reference in New Issue
Block a user