Moved dimensions logic into createPhoto
This commit is contained in:
parent
606df7a9dc
commit
8915c9e1c6
|
@ -32,7 +32,6 @@ class Generate {
|
|||
let images;
|
||||
let filename;
|
||||
let meta;
|
||||
let dimensions;
|
||||
let photo;
|
||||
try {
|
||||
inbox = await (0, promises_1.realpath)(this.inbox);
|
||||
|
@ -68,9 +67,6 @@ class Generate {
|
|||
this.log.info(image);
|
||||
filename = (0, path_1.basename)(image);
|
||||
meta = this.parseFilename(filename);
|
||||
dimensions = await this.getImageDimensions(image);
|
||||
meta.width = dimensions.width;
|
||||
meta.height = dimensions.height;
|
||||
photo = await this.createPhoto(image, meta);
|
||||
console.dir(meta);
|
||||
}
|
||||
|
@ -148,12 +144,13 @@ class Generate {
|
|||
}
|
||||
async createPhoto(image, meta) {
|
||||
const hash = await hash_1.Hashes.fileHash(image);
|
||||
const dimensions = await this.getImageDimensions(image);
|
||||
return {
|
||||
name: (0, path_1.basename)(image),
|
||||
original: meta.original,
|
||||
hash,
|
||||
width: meta.width,
|
||||
height: meta.height,
|
||||
width: dimensions.width,
|
||||
height: dimensions.height,
|
||||
format: meta.format,
|
||||
filmstock: meta.filmstock,
|
||||
location: meta.location,
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -21,8 +21,6 @@ interface Metadata {
|
|||
filmstock?: string;
|
||||
location? : string;
|
||||
description? : string;
|
||||
width? : number;
|
||||
height? : number;
|
||||
original?: string;
|
||||
}
|
||||
|
||||
|
@ -55,7 +53,6 @@ class Generate {
|
|||
let images : string[];
|
||||
let filename : string;
|
||||
let meta : Metadata;
|
||||
let dimensions : any;
|
||||
let photo : Photo;
|
||||
|
||||
try {
|
||||
|
@ -95,10 +92,6 @@ class Generate {
|
|||
this.log.info(image);
|
||||
filename = basename(image);
|
||||
meta = this.parseFilename(filename);
|
||||
dimensions = await this.getImageDimensions(image);
|
||||
meta.width = dimensions.width;
|
||||
meta.height = dimensions.height;
|
||||
|
||||
photo = await this.createPhoto(image, meta);
|
||||
|
||||
console.dir(meta)
|
||||
|
@ -183,12 +176,13 @@ class Generate {
|
|||
|
||||
private async createPhoto (image : string, meta : Metadata) : Promise<Photo> {
|
||||
const hash : string = await Hashes.fileHash(image);
|
||||
const dimensions : any = await this.getImageDimensions(image);
|
||||
return {
|
||||
name : basename(image),
|
||||
original: meta.original,
|
||||
hash,
|
||||
width : meta.width,
|
||||
height : meta.height,
|
||||
width : dimensions.width,
|
||||
height : dimensions.height,
|
||||
format : meta.format,
|
||||
filmstock : meta.filmstock,
|
||||
location : meta.location,
|
||||
|
|
Loading…
Reference in New Issue