Add .gitignore to exclude all node packages and lock files
This commit is contained in:
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import type { MediaParserDimensions } from '@remotion/media-parser';
|
||||
import type { ResizeOperation } from './mode';
|
||||
export declare const calculateNewSizeAfterResizing: ({ dimensions, resizeOperation, needsToBeMultipleOfTwo, }: {
|
||||
dimensions: MediaParserDimensions;
|
||||
resizeOperation: ResizeOperation | null;
|
||||
needsToBeMultipleOfTwo: boolean;
|
||||
}) => MediaParserDimensions;
|
||||
Generated
Vendored
+88
@@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.calculateNewSizeAfterResizing = void 0;
|
||||
const ensureMultipleOfTwo = ({ dimensions, needsToBeMultipleOfTwo, }) => {
|
||||
if (!needsToBeMultipleOfTwo) {
|
||||
return dimensions;
|
||||
}
|
||||
return {
|
||||
width: Math.floor(dimensions.width / 2) * 2,
|
||||
height: Math.floor(dimensions.height / 2) * 2,
|
||||
};
|
||||
};
|
||||
const calculateNewSizeAfterResizing = ({ dimensions, resizeOperation, needsToBeMultipleOfTwo, }) => {
|
||||
if (resizeOperation === null) {
|
||||
return ensureMultipleOfTwo({
|
||||
dimensions,
|
||||
needsToBeMultipleOfTwo,
|
||||
});
|
||||
}
|
||||
if (resizeOperation.mode === 'width') {
|
||||
return ensureMultipleOfTwo({
|
||||
dimensions: {
|
||||
width: resizeOperation.width,
|
||||
height: Math.round((resizeOperation.width / dimensions.width) * dimensions.height),
|
||||
},
|
||||
needsToBeMultipleOfTwo,
|
||||
});
|
||||
}
|
||||
if (resizeOperation.mode === 'height') {
|
||||
return ensureMultipleOfTwo({
|
||||
dimensions: {
|
||||
width: Math.round((resizeOperation.height / dimensions.height) * dimensions.width),
|
||||
height: resizeOperation.height,
|
||||
},
|
||||
needsToBeMultipleOfTwo,
|
||||
});
|
||||
}
|
||||
if (resizeOperation.mode === 'max-height') {
|
||||
const height = Math.min(dimensions.height, resizeOperation.maxHeight);
|
||||
return ensureMultipleOfTwo({
|
||||
dimensions: {
|
||||
width: Math.round((height / dimensions.height) * dimensions.width),
|
||||
height,
|
||||
},
|
||||
needsToBeMultipleOfTwo,
|
||||
});
|
||||
}
|
||||
if (resizeOperation.mode === 'max-width') {
|
||||
const width = Math.min(dimensions.width, resizeOperation.maxWidth);
|
||||
return ensureMultipleOfTwo({
|
||||
dimensions: {
|
||||
width,
|
||||
height: Math.round((width / dimensions.width) * dimensions.height),
|
||||
},
|
||||
needsToBeMultipleOfTwo,
|
||||
});
|
||||
}
|
||||
if (resizeOperation.mode === 'max-height-width') {
|
||||
const height = Math.min(dimensions.height, resizeOperation.maxHeight);
|
||||
const width = Math.min(dimensions.width, resizeOperation.maxWidth);
|
||||
const scale = Math.min(width / dimensions.width, height / dimensions.height);
|
||||
const actualWidth = Math.round(dimensions.width * scale);
|
||||
const actualHeight = Math.round(dimensions.height * scale);
|
||||
return ensureMultipleOfTwo({
|
||||
dimensions: {
|
||||
height: actualHeight,
|
||||
width: actualWidth,
|
||||
},
|
||||
needsToBeMultipleOfTwo,
|
||||
});
|
||||
}
|
||||
if (resizeOperation.mode === 'scale') {
|
||||
if (resizeOperation.scale <= 0) {
|
||||
throw new Error('Scale must be greater than 0');
|
||||
}
|
||||
const width = Math.round(dimensions.width * resizeOperation.scale);
|
||||
const height = Math.round(dimensions.height * resizeOperation.scale);
|
||||
return ensureMultipleOfTwo({
|
||||
dimensions: {
|
||||
width,
|
||||
height,
|
||||
},
|
||||
needsToBeMultipleOfTwo,
|
||||
});
|
||||
}
|
||||
throw new Error('Invalid resizing mode ' + resizeOperation);
|
||||
};
|
||||
exports.calculateNewSizeAfterResizing = calculateNewSizeAfterResizing;
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
export type ResizeOperation = {
|
||||
mode: 'width';
|
||||
width: number;
|
||||
} | {
|
||||
mode: 'height';
|
||||
height: number;
|
||||
} | {
|
||||
mode: 'max-height';
|
||||
maxHeight: number;
|
||||
} | {
|
||||
mode: 'max-width';
|
||||
maxWidth: number;
|
||||
} | {
|
||||
mode: 'max-height-width';
|
||||
maxHeight: number;
|
||||
maxWidth: number;
|
||||
} | {
|
||||
mode: 'scale';
|
||||
scale: number;
|
||||
};
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
Reference in New Issue
Block a user