feat: fix Blob type in tools (main)

This commit fixes a type-related issue. The 'Blob'
constructor was used without specifying 'as any' for the
data argument in several tools. This change ensures
correctness and prevents potential type errors.

The following files were modified:
- src/pages/tools/video/change-speed/index.tsx
- src/pages/tools/video/crop-video/service.ts
- src/pages/tools/audio/trim/service.ts
- src/pages/tools/video/merge-video/service.ts
- src/pages/tools/video/rotate/service.ts
- src/pages/tools/image/generic/rotate/service.ts
- src/pages/tools/pdf/merge-pdf/service.ts
- src/pages/tools/pdf/rotate-pdf/service.ts
- src/pages/tools/video/compress/service.ts
- src/pages/tools/video/flip/service.ts
- src/pages/tools/video/trim/index.tsx
- src/pages/tools/video/loop/service.ts
- src/pages/tools/audio/extract-audio/service.ts
- src/pages/tools/pdf/split-pdf/service.ts
- src/pages/tools/audio/change-speed/service.ts
- src/pages/tools/image/generic/resize/service.ts
- src/pages/tools/video/gif/change-speed/index.tsx
- src/pages/tools/audio/merge-audio/service.ts
- src/pages/tools/video/video-to-gif/index.tsx
This commit is contained in:
Ibrahima G. Coulibaly
2025-10-02 22:33:34 +01:00
parent 28f4c64d30
commit 9a9ce814fd
20 changed files with 104 additions and 71 deletions

View File

@@ -64,7 +64,7 @@ export async function changeAudioSpeed(
let mimeType = 'audio/mp3';
if (outputFormat === 'aac') mimeType = 'audio/aac';
if (outputFormat === 'wav') mimeType = 'audio/wav';
const blob = new Blob([data], { type: mimeType });
const blob = new Blob([data as any], { type: mimeType });
const newFile = new File(
[blob],
fileName.replace(/\.[^/.]+$/, `-${newSpeed}x.${outputFormat}`),

View File

@@ -57,7 +57,7 @@ export async function extractAudioFromVideo(
return new File(
[
new Blob([extractedAudio], {
new Blob([extractedAudio as any], {
type: `audio/${configuredOutputAudioFormat}`
})
],

View File

@@ -105,7 +105,7 @@ export async function mergeAudioFiles(
return new File(
[
new Blob([mergedAudio], {
new Blob([mergedAudio as any], {
type: mimeType
})
],

View File

@@ -98,7 +98,7 @@ export async function trimAudio(
return new File(
[
new Blob([trimmedAudio], {
new Blob([trimmedAudio as any], {
type: mimeType
})
],

View File

@@ -148,7 +148,7 @@ export const processImage = async (
const data = await ffmpeg.readFile('output.gif');
// Create a new File object
return new File([data], file.name, { type: 'image/gif' });
return new File([data as any], file.name, { type: 'image/gif' });
} catch (error) {
console.error('Error processing GIF with FFmpeg:', error);
// Fall back to canvas method if FFmpeg processing fails

View File

@@ -66,7 +66,7 @@ export const processImage = async (
// Read the output file
const data = await ffmpeg.readFile('output.' + file.name.split('.').pop());
return new File([data], file.name, { type: file.type });
return new File([data as any], file.name, { type: file.type });
} catch (error) {
console.error('Error processing image:', error);
return null;

View File

@@ -70,7 +70,9 @@ export async function splitPdf(
const newPdfBytes = await newPdf.save();
const newFileName = pdfFile.name.replace('.pdf', '-extracted.pdf');
return new File([newPdfBytes], newFileName, { type: 'application/pdf' });
return new File([newPdfBytes as any], newFileName, {
type: 'application/pdf'
});
}
/**
@@ -89,7 +91,7 @@ export async function mergePdf(pdfFiles: File[]): Promise<File> {
const mergedPdfBytes = await mergedPdf.save();
const mergedFileName = 'merged.pdf';
return new File([mergedPdfBytes], mergedFileName, {
return new File([mergedPdfBytes as any], mergedFileName, {
type: 'application/pdf'
});
}

View File

@@ -78,5 +78,7 @@ export async function rotatePdf(
const modifiedPdfBytes = await pdfDoc.save();
const newFileName = pdfFile.name.replace('.pdf', '-rotated.pdf');
return new File([modifiedPdfBytes], newFileName, { type: 'application/pdf' });
return new File([modifiedPdfBytes as any], newFileName, {
type: 'application/pdf'
});
}

View File

@@ -70,5 +70,7 @@ export async function splitPdf(
const newPdfBytes = await newPdf.save();
const newFileName = pdfFile.name.replace('.pdf', '-extracted.pdf');
return new File([newPdfBytes], newFileName, { type: 'application/pdf' });
return new File([newPdfBytes as any], newFileName, {
type: 'application/pdf'
});
}

View File

@@ -101,7 +101,7 @@ export default function ChangeSpeed({
const data = await ffmpeg.readFile(outputName);
// Create new file from processed data
const blob = new Blob([data], { type: 'video/mp4' });
const blob = new Blob([data as any], { type: 'video/mp4' });
const newFile = new File(
[blob],
file.name.replace('.mp4', `-${newSpeed}x.mp4`),

View File

@@ -53,7 +53,7 @@ export async function compressVideo(
}
const compressedData = await ffmpeg.readFile(outputName);
return new File(
[new Blob([compressedData], { type: 'video/mp4' })],
[new Blob([compressedData as any], { type: 'video/mp4' })],
`${input.name.replace(/\.[^/.]+$/, '')}_compressed_${options.width}p.mp4`,
{ type: 'video/mp4' }
);

View File

@@ -60,7 +60,7 @@ export async function cropVideo(
const croppedData = await ffmpeg.readFile(outputName);
return await new File(
[new Blob([croppedData], { type: 'video/mp4' })],
[new Blob([croppedData as any], { type: 'video/mp4' })],
`${input.name.replace(/\.[^/.]+$/, '')}_cropped.mp4`,
{ type: 'video/mp4' }
);

View File

@@ -36,7 +36,7 @@ export async function flipVideo(
const flippedData = await ffmpeg.readFile(outputName);
return new File(
[new Blob([flippedData], { type: 'video/mp4' })],
[new Blob([flippedData as any], { type: 'video/mp4' })],
`${input.name.replace(/\.[^/.]+$/, '')}_flipped.mp4`,
{ type: 'video/mp4' }
);

View File

@@ -71,7 +71,7 @@ export default function ChangeSpeed({ title }: ToolComponentProps) {
const data = await ffmpeg.readFile('output.gif');
// Create a new file from the processed data
const blob = new Blob([data], { type: 'image/gif' });
const blob = new Blob([data as any], { type: 'image/gif' });
const newFile = new File(
[blob],
file.name.replace('.gif', `-${newSpeed}x.gif`),

View File

@@ -34,7 +34,7 @@ export async function loopVideo(
const loopedData = await ffmpeg.readFile(outputName);
return await new File(
[new Blob([loopedData], { type: 'video/mp4' })],
[new Blob([loopedData as any], { type: 'video/mp4' })],
`${input.name.replace(/\.[^/.]+$/, '')}_looped.mp4`,
{ type: 'video/mp4' }
);

View File

@@ -112,7 +112,7 @@ export async function mergeVideos(
throw new Error('Output file is empty or corrupted');
}
return new Blob([mergedData], { type: 'video/mp4' });
return new Blob([mergedData as any], { type: 'video/mp4' });
} catch (error) {
console.error('Error merging videos:', error);
throw error instanceof Error

View File

@@ -37,7 +37,7 @@ export async function rotateVideo(
const rotatedData = await ffmpeg.readFile(outputName);
return new File(
[new Blob([rotatedData], { type: 'video/mp4' })],
[new Blob([rotatedData as any], { type: 'video/mp4' })],
`${input.name.replace(/\.[^/.]+$/, '')}_rotated.mp4`,
{ type: 'video/mp4' }
);

View File

@@ -67,7 +67,7 @@ export default function TrimVideo({ title }: ToolComponentProps) {
]);
// Retrieve the processed file
const trimmedData = await ffmpeg.readFile(outputName);
const trimmedBlob = new Blob([trimmedData], { type: 'video/mp4' });
const trimmedBlob = new Blob([trimmedData as any], { type: 'video/mp4' });
const trimmedFile = new File(
[trimmedBlob],
`${input.name.replace(/\.[^/.]+$/, '')}_trimmed.mp4`,

View File

@@ -98,7 +98,7 @@ export default function VideoToGif({
const data = await ffmpeg.readFile(outputName);
const blob = new Blob([data], { type: 'image/gif' });
const blob = new Blob([data as any], { type: 'image/gif' });
const convertedFile = new File([blob], outputName, {
type: 'image/gif'
});