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