Skip to content

Commit 6bd4780

Browse files
authored
upgrade file-type (#1108)
1 parent e4d6af0 commit 6bd4780

File tree

3 files changed

+99
-52
lines changed

3 files changed

+99
-52
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"any-base": "^1.1.0",
4040
"buffer": "^5.2.0",
4141
"exif-parser": "^0.1.12",
42-
"file-type": "^9.0.0",
42+
"file-type": "^16.5.4",
4343
"load-bmfont": "^1.3.1",
4444
"mkdirp": "^0.5.1",
4545
"phin": "^2.9.1",

packages/core/src/utils/image-bitmap.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fileType from 'file-type';
1+
import FileType from 'file-type';
22

33
import EXIFParser from 'exif-parser';
44
import { throwError } from '@jimp/utils';
@@ -7,8 +7,8 @@ import * as constants from '../constants';
77
import * as MIME from './mime';
88
import promisify from './promisify';
99

10-
function getMIMEFromBuffer(buffer, path) {
11-
const fileTypeFromBuffer = fileType(buffer);
10+
async function getMIMEFromBuffer(buffer, path) {
11+
const fileTypeFromBuffer = await FileType.fromBuffer(buffer);
1212

1313
if (fileTypeFromBuffer) {
1414
// If fileType returns something for buffer, then return the mime given
@@ -149,8 +149,8 @@ function exifRotate(img) {
149149
}
150150

151151
// parses a bitmap from the constructor to the JIMP bitmap property
152-
export function parseBitmap(data, path, cb) {
153-
const mime = getMIMEFromBuffer(data, path);
152+
export async function parseBitmap(data, path, cb) {
153+
const mime = await getMIMEFromBuffer(data, path);
154154

155155
if (typeof mime !== 'string') {
156156
return cb(new Error('Could not find MIME for Buffer <' + path + '>'));

0 commit comments

Comments
 (0)