11import { Bitmap , Format , JimpClass , Edge } from "@jimp/types" ;
22import { cssColorToHex , scan , scanIterator } from "@jimp/utils" ;
3- import fileType from "file-type/core .js" ;
3+ import { fileTypeFromBuffer } from "./utils/fileTypeFromBuffer .js" ;
44import { to } from "await-to-js" ;
55import { existsSync , readFile , writeFile } from "@jimp/file-ops" ;
66import mime from "mime/lite.js" ;
@@ -90,7 +90,7 @@ export interface JimpPlugin {
9090}
9191
9292type UnionToIntersection < U > = ( U extends any ? ( k : U ) => void : never ) extends (
93- k : infer I
93+ k : infer I ,
9494) => void
9595 ? I
9696 : never ;
@@ -225,7 +225,7 @@ export function createJimp<
225225 */
226226 static async read (
227227 url : string | Buffer | ArrayBuffer ,
228- options ?: MimeTypeToDecodeOptions
228+ options ?: MimeTypeToDecodeOptions ,
229229 ) {
230230 if ( Buffer . isBuffer ( url ) || url instanceof ArrayBuffer ) {
231231 return this . fromBuffer ( url ) ;
@@ -292,8 +292,8 @@ export function createJimp<
292292 if ( Array . isArray ( bitmap . data ) ) {
293293 data = Buffer . concat (
294294 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+ ) ,
297297 ) ;
298298 }
299299
@@ -329,12 +329,12 @@ export function createJimp<
329329 */
330330 static async fromBuffer (
331331 buffer : Buffer | ArrayBuffer ,
332- options ?: MimeTypeToDecodeOptions
332+ options ?: MimeTypeToDecodeOptions ,
333333 ) {
334334 const actualBuffer =
335335 buffer instanceof ArrayBuffer ? bufferFromArrayBuffer ( buffer ) : buffer ;
336336
337- const mime = await fileType . fromBuffer ( actualBuffer ) ;
337+ const mime = await fileTypeFromBuffer ( actualBuffer ) ;
338338
339339 if ( ! mime || ! mime . mime ) {
340340 throw new Error ( "Could not find MIME for Buffer" ) ;
@@ -347,7 +347,7 @@ export function createJimp<
347347 }
348348
349349 const image = new CustomJimp (
350- await format . decode ( actualBuffer , options ?. [ format . mime ] )
350+ await format . decode ( actualBuffer , options ?. [ format . mime ] ) ,
351351 ) as InstanceType < typeof CustomJimp > & ExtraMethodMap ;
352352
353353 image . mime = mime . mime ;
@@ -500,7 +500,7 @@ export function createJimp<
500500 const mimeType = mime . getType ( path ) ;
501501 await writeFile (
502502 path ,
503- await this . getBuffer ( mimeType as SupportedMimeTypes , options )
503+ await this . getBuffer ( mimeType as SupportedMimeTypes , options ) ,
504504 ) ;
505505 }
506506
@@ -701,7 +701,7 @@ export function createJimp<
701701 mode ?: BlendMode ;
702702 opacitySource ?: number ;
703703 opacityDest ?: number ;
704- } = { }
704+ } = { } ,
705705 ) {
706706 return composite ( this , src , x , y , options ) ;
707707 }
@@ -731,14 +731,14 @@ export function createJimp<
731731 y : number ,
732732 w : number ,
733733 h : number ,
734- cb : ( x : number , y : number , idx : number ) => any
734+ cb : ( x : number , y : number , idx : number ) => any ,
735735 ) : this;
736736 scan (
737737 x : number | ( ( x : number , y : number , idx : number ) => any ) ,
738738 y ?: number ,
739739 w ?: number ,
740740 h ?: number ,
741- f ?: ( x : number , y : number , idx : number ) => any
741+ f ?: ( x : number , y : number , idx : number ) => any ,
742742 ) : this {
743743 return scan ( this , x as any , y as any , w as any , h as any , f as any ) ;
744744 }
0 commit comments