mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-23 01:27:14 +02:00
xmp-rating valid values now 1-5. 0 means "unrated" and the attribute does not exist with value 0
This commit is contained in:
parent
77982e6c10
commit
b071b6daae
@ -134,7 +134,7 @@ export class MediaMetadataEntity implements MediaMetadata {
|
||||
|
||||
@Column('tinyint', {unsigned: false})
|
||||
@Index()
|
||||
rating: -1 | 0 | 1 | 2 | 3 | 4 | 5;
|
||||
rating: 0 | 1 | 2 | 3 | 4 | 5;
|
||||
|
||||
@OneToMany(() => PersonJunctionTable, (junctionTable) => junctionTable.media)
|
||||
personJunction: PersonJunctionTable[];
|
||||
|
@ -3,6 +3,7 @@ import { imageSize } from 'image-size';
|
||||
import { Config } from '../../../common/config/private/Config';
|
||||
import { FaceRegion, PhotoMetadata } from '../../../common/entities/PhotoDTO';
|
||||
import { VideoMetadata } from '../../../common/entities/VideoDTO';
|
||||
import { RatingTypes } from '../../../common/entities/MediaDTO';
|
||||
import { Logger } from '../../Logger';
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
@ -513,17 +514,17 @@ export class MetadataLoader {
|
||||
private static mapRating(metadata: PhotoMetadata, exif: any) {
|
||||
if (exif.xmp &&
|
||||
exif.xmp.Rating !== undefined) {
|
||||
metadata.rating = exif.xmp.Rating;
|
||||
}
|
||||
if (metadata.rating !== undefined) {
|
||||
if (metadata.rating < -1) { //Rating -1 means "rejected" according to adobe's spec
|
||||
metadata.rating = -1;
|
||||
} else if (metadata.rating > 5) {
|
||||
const rting = Math.round(exif.xmp.Rating);
|
||||
if (rting < 0) {
|
||||
//We map all ratings below 0 to 0. Lightroom supports value -1, but most other tools (including this) don't.
|
||||
//Rating 0 means "unrated" according to adobe's spec, so we delete the attribute in pigallery for the same effect
|
||||
delete metadata.rating;
|
||||
} else if (rting > 5) { //map all ratings above 5 to 5
|
||||
metadata.rating = 5;
|
||||
} else {
|
||||
metadata.rating = (rting as RatingTypes);
|
||||
}
|
||||
}
|
||||
} //else {
|
||||
//metadata.rating = 0; //Rating 0 means "unrated" according to adobe's spec
|
||||
//}
|
||||
}
|
||||
|
||||
private static mapFaces(metadata: PhotoMetadata, exif: any, orientation: number) {
|
||||
|
@ -11,7 +11,7 @@ export interface MediaDTO extends FileDTO {
|
||||
missingThumbnails?: number;
|
||||
}
|
||||
|
||||
export type RatingTypes = -1 | 0 | 1 | 2 | 3 | 4 | 5;
|
||||
export type RatingTypes = 0 | 1 | 2 | 3 | 4 | 5;
|
||||
|
||||
export interface MediaMetadata {
|
||||
size: MediaDimension;
|
||||
|
@ -17,7 +17,6 @@
|
||||
},
|
||||
"keywords": [
|
||||
],
|
||||
"rating": -1,
|
||||
"faces": [
|
||||
{
|
||||
"box": {
|
||||
|
@ -16,7 +16,6 @@
|
||||
},
|
||||
"keywords": [
|
||||
],
|
||||
"rating": -1,
|
||||
"faces": [
|
||||
{
|
||||
"box": {
|
||||
|
@ -17,7 +17,6 @@
|
||||
},
|
||||
"keywords": [
|
||||
],
|
||||
"rating": -1,
|
||||
"faces": [
|
||||
{
|
||||
"box": {
|
||||
|
@ -17,7 +17,6 @@
|
||||
},
|
||||
"keywords": [
|
||||
],
|
||||
"rating": -1,
|
||||
"faces": [
|
||||
{
|
||||
"box": {
|
||||
|
Loading…
Reference in New Issue
Block a user