Moved dimensions logic into createPhoto

This commit is contained in:
mmcwilliams 2024-12-05 14:57:01 -05:00
parent 606df7a9dc
commit 8915c9e1c6
3 changed files with 7 additions and 16 deletions

9
dist/generate.js vendored
View File

@ -32,7 +32,6 @@ class Generate {
let images; let images;
let filename; let filename;
let meta; let meta;
let dimensions;
let photo; let photo;
try { try {
inbox = await (0, promises_1.realpath)(this.inbox); inbox = await (0, promises_1.realpath)(this.inbox);
@ -68,9 +67,6 @@ class Generate {
this.log.info(image); this.log.info(image);
filename = (0, path_1.basename)(image); filename = (0, path_1.basename)(image);
meta = this.parseFilename(filename); meta = this.parseFilename(filename);
dimensions = await this.getImageDimensions(image);
meta.width = dimensions.width;
meta.height = dimensions.height;
photo = await this.createPhoto(image, meta); photo = await this.createPhoto(image, meta);
console.dir(meta); console.dir(meta);
} }
@ -148,12 +144,13 @@ class Generate {
} }
async createPhoto(image, meta) { async createPhoto(image, meta) {
const hash = await hash_1.Hashes.fileHash(image); const hash = await hash_1.Hashes.fileHash(image);
const dimensions = await this.getImageDimensions(image);
return { return {
name: (0, path_1.basename)(image), name: (0, path_1.basename)(image),
original: meta.original, original: meta.original,
hash, hash,
width: meta.width, width: dimensions.width,
height: meta.height, height: dimensions.height,
format: meta.format, format: meta.format,
filmstock: meta.filmstock, filmstock: meta.filmstock,
location: meta.location, location: meta.location,

File diff suppressed because one or more lines are too long

View File

@ -21,8 +21,6 @@ interface Metadata {
filmstock?: string; filmstock?: string;
location? : string; location? : string;
description? : string; description? : string;
width? : number;
height? : number;
original?: string; original?: string;
} }
@ -55,7 +53,6 @@ class Generate {
let images : string[]; let images : string[];
let filename : string; let filename : string;
let meta : Metadata; let meta : Metadata;
let dimensions : any;
let photo : Photo; let photo : Photo;
try { try {
@ -95,10 +92,6 @@ class Generate {
this.log.info(image); this.log.info(image);
filename = basename(image); filename = basename(image);
meta = this.parseFilename(filename); meta = this.parseFilename(filename);
dimensions = await this.getImageDimensions(image);
meta.width = dimensions.width;
meta.height = dimensions.height;
photo = await this.createPhoto(image, meta); photo = await this.createPhoto(image, meta);
console.dir(meta) console.dir(meta)
@ -183,12 +176,13 @@ class Generate {
private async createPhoto (image : string, meta : Metadata) : Promise<Photo> { private async createPhoto (image : string, meta : Metadata) : Promise<Photo> {
const hash : string = await Hashes.fileHash(image); const hash : string = await Hashes.fileHash(image);
const dimensions : any = await this.getImageDimensions(image);
return { return {
name : basename(image), name : basename(image),
original: meta.original, original: meta.original,
hash, hash,
width : meta.width, width : dimensions.width,
height : meta.height, height : dimensions.height,
format : meta.format, format : meta.format,
filmstock : meta.filmstock, filmstock : meta.filmstock,
location : meta.location, location : meta.location,