Refactor: remove AGPL imgly dependency and migrate background removal to python backend

This commit is contained in:
2026-06-02 14:50:25 -05:00
parent 560a413c1e
commit f998e454fe
25 changed files with 601 additions and 97 deletions
+32
View File
@@ -0,0 +1,32 @@
export async function detectMediaDimensionsAndAspect(
url: string,
type: 'video' | 'image'
): Promise<{ width: number; height: number; format: 'video' | 'image'; aspect: string }> {
return new Promise((resolve, reject) => {
if (type === 'image') {
const img = new Image();
img.onload = () => {
resolve({
width: img.width,
height: img.height,
format: 'image',
aspect: `${img.width}:${img.height}`,
});
};
img.onerror = () => reject(new Error('Failed to load image to detect dimensions.'));
img.src = url;
} else {
const video = document.createElement('video');
video.onloadedmetadata = () => {
resolve({
width: video.videoWidth,
height: video.videoHeight,
format: 'video',
aspect: `${video.videoWidth}:${video.videoHeight}`,
});
};
video.onerror = () => reject(new Error('Failed to load video to detect dimensions.'));
video.src = url;
}
});
}