1
1
import { Bitmap , Format , JimpClass , Edge } from "@jimp/types" ;
2
2
import { cssColorToHex , scan , scanIterator } from "@jimp/utils" ;
3
- import fileType from "file-type/core .js" ;
3
+ import { fileTypeFromBuffer } from "./utils/fileTypeFromBuffer .js" ;
4
4
import { to } from "await-to-js" ;
5
5
import { existsSync , readFile , writeFile } from "@jimp/file-ops" ;
6
6
import mime from "mime/lite.js" ;
@@ -90,7 +90,7 @@ export interface JimpPlugin {
90
90
}
91
91
92
92
type UnionToIntersection < U > = ( U extends any ? ( k : U ) => void : never ) extends (
93
- k : infer I
93
+ k : infer I ,
94
94
) => void
95
95
? I
96
96
: never ;
@@ -225,7 +225,7 @@ export function createJimp<
225
225
*/
226
226
static async read (
227
227
url : string | Buffer | ArrayBuffer ,
228
- options ?: MimeTypeToDecodeOptions
228
+ options ?: MimeTypeToDecodeOptions ,
229
229
) {
230
230
if ( Buffer . isBuffer ( url ) || url instanceof ArrayBuffer ) {
231
231
return this . fromBuffer ( url ) ;
@@ -292,8 +292,8 @@ export function createJimp<
292
292
if ( Array . isArray ( bitmap . data ) ) {
293
293
data = Buffer . concat (
294
294
bitmap . data . map ( ( hex ) =>
295
- Buffer . from ( hex . toString ( 16 ) . padStart ( 8 , "0" ) , "hex" )
296
- )
295
+ Buffer . from ( hex . toString ( 16 ) . padStart ( 8 , "0" ) , "hex" ) ,
296
+ ) ,
297
297
) ;
298
298
}
299
299
@@ -329,12 +329,12 @@ export function createJimp<
329
329
*/
330
330
static async fromBuffer (
331
331
buffer : Buffer | ArrayBuffer ,
332
- options ?: MimeTypeToDecodeOptions
332
+ options ?: MimeTypeToDecodeOptions ,
333
333
) {
334
334
const actualBuffer =
335
335
buffer instanceof ArrayBuffer ? bufferFromArrayBuffer ( buffer ) : buffer ;
336
336
337
- const mime = await fileType . fromBuffer ( actualBuffer ) ;
337
+ const mime = await fileTypeFromBuffer ( actualBuffer ) ;
338
338
339
339
if ( ! mime || ! mime . mime ) {
340
340
throw new Error ( "Could not find MIME for Buffer" ) ;
@@ -347,7 +347,7 @@ export function createJimp<
347
347
}
348
348
349
349
const image = new CustomJimp (
350
- await format . decode ( actualBuffer , options ?. [ format . mime ] )
350
+ await format . decode ( actualBuffer , options ?. [ format . mime ] ) ,
351
351
) as InstanceType < typeof CustomJimp > & ExtraMethodMap ;
352
352
353
353
image . mime = mime . mime ;
@@ -500,7 +500,7 @@ export function createJimp<
500
500
const mimeType = mime . getType ( path ) ;
501
501
await writeFile (
502
502
path ,
503
- await this . getBuffer ( mimeType as SupportedMimeTypes , options )
503
+ await this . getBuffer ( mimeType as SupportedMimeTypes , options ) ,
504
504
) ;
505
505
}
506
506
@@ -701,7 +701,7 @@ export function createJimp<
701
701
mode ?: BlendMode ;
702
702
opacitySource ?: number ;
703
703
opacityDest ?: number ;
704
- } = { }
704
+ } = { } ,
705
705
) {
706
706
return composite ( this , src , x , y , options ) ;
707
707
}
@@ -731,14 +731,14 @@ export function createJimp<
731
731
y : number ,
732
732
w : number ,
733
733
h : number ,
734
- cb : ( x : number , y : number , idx : number ) => any
734
+ cb : ( x : number , y : number , idx : number ) => any ,
735
735
) : this;
736
736
scan (
737
737
x : number | ( ( x : number , y : number , idx : number ) => any ) ,
738
738
y ?: number ,
739
739
w ?: number ,
740
740
h ?: number ,
741
- f ?: ( x : number , y : number , idx : number ) => any
741
+ f ?: ( x : number , y : number , idx : number ) => any ,
742
742
) : this {
743
743
return scan ( this , x as any , y as any , w as any , h as any , f as any ) ;
744
744
}
0 commit comments