mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-23 16:09:30 +02:00
feat: change gif speed
This commit is contained in:
18
src/utils/gif.ts
Normal file
18
src/utils/gif.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { GifBinary } from 'omggif';
|
||||
|
||||
export function gifBinaryToFile(
|
||||
gifBinary: GifBinary,
|
||||
fileName: string,
|
||||
mimeType: string = 'image/gif'
|
||||
): File {
|
||||
// Convert GifBinary to Uint8Array
|
||||
const uint8Array = new Uint8Array(gifBinary.length);
|
||||
for (let i = 0; i < gifBinary.length; i++) {
|
||||
uint8Array[i] = gifBinary[i];
|
||||
}
|
||||
|
||||
const blob = new Blob([uint8Array], { type: mimeType });
|
||||
|
||||
// Create File from Blob
|
||||
return new File([blob], fileName, { type: mimeType });
|
||||
}
|
Reference in New Issue
Block a user