mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
Merge pull request #879 from grasdk/bug/heic-dimensions
updated image-size dependency to read dimensions from heic file
This commit is contained in:
commit
8c86dcbf6f
13
package-lock.json
generated
13
package-lock.json
generated
@ -20,7 +20,7 @@
|
|||||||
"express": "4.18.2",
|
"express": "4.18.2",
|
||||||
"express-unless": "2.1.3",
|
"express-unless": "2.1.3",
|
||||||
"fluent-ffmpeg": "2.1.2",
|
"fluent-ffmpeg": "2.1.2",
|
||||||
"image-size": "1.0.2",
|
"image-size": "1.1.1",
|
||||||
"locale": "0.1.0",
|
"locale": "0.1.0",
|
||||||
"node-geocoder": "4.2.0",
|
"node-geocoder": "4.2.0",
|
||||||
"nodemailer": "6.9.4",
|
"nodemailer": "6.9.4",
|
||||||
@ -12233,8 +12233,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/image-size": {
|
"node_modules/image-size": {
|
||||||
"version": "1.0.2",
|
"version": "1.1.1",
|
||||||
"license": "MIT",
|
"resolved": "https://registry.npmjs.org/image-size/-/image-size-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-541xKlUw6jr/6gGuk92F+mYM5zaFAc5ahphvkqvNe2bQ6gVBkd6bfrmVJ2t4KDAfikAYZyIqTnktX3i6/aQDrQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"queue": "6.0.2"
|
"queue": "6.0.2"
|
||||||
},
|
},
|
||||||
@ -12242,7 +12243,7 @@
|
|||||||
"image-size": "bin/image-size.js"
|
"image-size": "bin/image-size.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.0.0"
|
"node": ">=16.x"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/immutable": {
|
"node_modules/immutable": {
|
||||||
@ -29977,7 +29978,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"image-size": {
|
"image-size": {
|
||||||
"version": "1.0.2",
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/image-size/-/image-size-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-541xKlUw6jr/6gGuk92F+mYM5zaFAc5ahphvkqvNe2bQ6gVBkd6bfrmVJ2t4KDAfikAYZyIqTnktX3i6/aQDrQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"queue": "6.0.2"
|
"queue": "6.0.2"
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
"express": "4.18.2",
|
"express": "4.18.2",
|
||||||
"express-unless": "2.1.3",
|
"express-unless": "2.1.3",
|
||||||
"fluent-ffmpeg": "2.1.2",
|
"fluent-ffmpeg": "2.1.2",
|
||||||
"image-size": "1.0.2",
|
"image-size": "1.1.1",
|
||||||
"locale": "0.1.0",
|
"locale": "0.1.0",
|
||||||
"node-geocoder": "4.2.0",
|
"node-geocoder": "4.2.0",
|
||||||
"nodemailer": "6.9.4",
|
"nodemailer": "6.9.4",
|
||||||
|
@ -205,6 +205,13 @@ export class MetadataLoader {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
//in case of failure, set dimensions to 0 so they may be read via tags
|
//in case of failure, set dimensions to 0 so they may be read via tags
|
||||||
metadata.size = { width: 0, height: 0 };
|
metadata.size = { width: 0, height: 0 };
|
||||||
|
} finally {
|
||||||
|
if (isNaN(metadata.size.width) || metadata.size.width == null) {
|
||||||
|
metadata.size.width = 0;
|
||||||
|
}
|
||||||
|
if (isNaN(metadata.size.height) || metadata.size.height == null) {
|
||||||
|
metadata.size.height = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -297,10 +304,10 @@ export class MetadataLoader {
|
|||||||
|
|
||||||
private static mapImageDimensions(metadata: PhotoMetadata, exif: any, orientation: number) {
|
private static mapImageDimensions(metadata: PhotoMetadata, exif: any, orientation: number) {
|
||||||
if (metadata.size.width <= 0) {
|
if (metadata.size.width <= 0) {
|
||||||
metadata.size.width = exif.ifd0?.ImageWidth || exif.exif?.ExifImageWidth;
|
metadata.size.width = exif.ifd0?.ImageWidth || exif.exif?.ExifImageWidth || metadata.size.width;
|
||||||
}
|
}
|
||||||
if (metadata.size.height <= 0) {
|
if (metadata.size.height <= 0) {
|
||||||
metadata.size.height = exif.ifd0?.ImageHeight || exif.exif?.ExifImageHeight;
|
metadata.size.height = exif.ifd0?.ImageHeight || exif.exif?.ExifImageHeight || metadata.size.height;
|
||||||
}
|
}
|
||||||
metadata.size.height = Math.max(metadata.size.height, 1); //ensure height dimension is positive
|
metadata.size.height = Math.max(metadata.size.height, 1); //ensure height dimension is positive
|
||||||
metadata.size.width = Math.max(metadata.size.width, 1); //ensure width dimension is positive
|
metadata.size.width = Math.max(metadata.size.width, 1); //ensure width dimension is positive
|
||||||
|
BIN
test/backend/assets/parsingfromheic.heic
Normal file
BIN
test/backend/assets/parsingfromheic.heic
Normal file
Binary file not shown.
15
test/backend/assets/parsingfromheic.json
Normal file
15
test/backend/assets/parsingfromheic.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"positionData": {
|
||||||
|
"GPSData": {
|
||||||
|
"latitude": 9.061331,
|
||||||
|
"longitude": 38.761711
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"creationDate": 1706438594000,
|
||||||
|
"creationDateOffset": "+03:00",
|
||||||
|
"fileSize": 2158564,
|
||||||
|
"size": {
|
||||||
|
"height": 512,
|
||||||
|
"width": 512
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,12 @@ describe('MetadataLoader', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should load heic', async () => {
|
||||||
|
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/parsingfromheic.heic'));
|
||||||
|
const expected = require(path.join(__dirname, '/../../../assets/parsingfromheic.json'));
|
||||||
|
expect(Utils.clone(data)).to.be.deep.equal(expected);
|
||||||
|
});
|
||||||
|
|
||||||
it('should load png', async () => {
|
it('should load png', async () => {
|
||||||
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/test_png.png'));
|
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/test_png.png'));
|
||||||
const expected = require(path.join(__dirname, '/../../../assets/test_png.json'));
|
const expected = require(path.join(__dirname, '/../../../assets/test_png.json'));
|
||||||
|
Loading…
Reference in New Issue
Block a user