Skip to content

Commit

Permalink
evospace images fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleaxe committed Mar 25, 2024
1 parent 6dcbdcc commit 1edc5a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions data/evospace/grabber/version19/prepare-images.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ export class ImagesList {
async addImageFileAsync(imagePath) {
const imageFile = path.basename(imagePath);
const imageName = path.basename(imageFile, path.extname(imageFile));
let imageObject;
try {
const imageObject = await Jimp.read(imagePath);
imageObject = await Jimp.read(imagePath);
this.#images.set(imageName, imageObject);
} catch(err) {
let error = err;
if(this.imagesBackup) {
const imagePath2 = path.join(this.imagesBackup, imageFile);
try {
const imageObject = await Jimp.read(imagePath2);
imageObject = await Jimp.read(imagePath2);
this.#images.set(imageName, imageObject);
error = undefined;
} catch(err0) {}
Expand All @@ -33,14 +34,15 @@ export class ImagesList {
console.warn(`Error reading image ${imageName}: ${error.message}`);
}
}
if(imageObject &&
((imageObject.bitmap.height != ImagesList.RESOLUTION) || (imageObject.bitmap.width != ImagesList.RESOLUTION))) {
console.warn(`Invalid image resolution: ${imageObject.bitmap.width} x ${imageObject.bitmap.height} => ${imageName}`);
imageObject.resize(ImagesList.RESOLUTION, ImagesList.RESOLUTION, Jimp.RESIZE_BEZIER);
}
}
addImageObject(imageName, imageObject) {
if(this.#images.has(imageName))
console.warn(`Duplicate image name: ${imageName}`);
if((imageObject.bitmap.height != ImagesList.RESOLUTION) || (imageObject.bitmap.width != ImagesList.RESOLUTION)) {
console.warn(`Invalid image resolution: ${imageObject.bitmap.width} x ${imageObject.bitmap.height} => ${imageName}`);
imageObject.resize(ImagesList.RESOLUTION, ImagesList.RESOLUTION, Jimp.RESIZE_BEZIER);
}
this.#images.set(imageName, imageObject);
}
getImageObject(imageName) {
Expand Down
Binary file modified data/evospace/parsed/images.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1edc5a1

Please sign in to comment.