Improved animated image handling.
This commit is contained in:
19
src/media.js
19
src/media.js
@@ -319,7 +319,7 @@ async function storeImageFile(media, hashDir, hashSubDir, filename, filedir, fil
|
||||
fsPromises.mkdir(path.join(config.media.path, lazydir), { recursive: true }),
|
||||
]);
|
||||
|
||||
const image = sharp(media.file.path);
|
||||
const image = sharp(media.file.path, { pages: -1 });
|
||||
const isProcessed = media.meta.subtype !== 'jpeg' || media.process;
|
||||
|
||||
const [info, stats] = await Promise.all([
|
||||
@@ -344,10 +344,17 @@ async function storeImageFile(media, hashDir, hashSubDir, filename, filedir, fil
|
||||
}
|
||||
|
||||
if (isProcessed) {
|
||||
// convert to JPEG and write to permanent location
|
||||
await image
|
||||
.jpeg()
|
||||
.toFile(path.join(config.media.path, filepath));
|
||||
if (info.pages) {
|
||||
// convert animated image to WebP and write to permanent location
|
||||
await image
|
||||
.webp()
|
||||
.toFile(path.join(config.media.path, filepath));
|
||||
} else {
|
||||
// convert to JPEG and write to permanent location
|
||||
await image
|
||||
.jpeg()
|
||||
.toFile(path.join(config.media.path, filepath));
|
||||
}
|
||||
}
|
||||
|
||||
// generate thumbnail and lazy
|
||||
@@ -424,7 +431,7 @@ async function storeFile(media, options) {
|
||||
}
|
||||
}
|
||||
|
||||
if (media.meta.type === 'image' && media.meta.subtype !== 'gif') {
|
||||
if (media.meta.type === 'image') {
|
||||
return storeImageFile(media, hashDir, hashSubDir, filename, filedir, filepath, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const mime = require('mime');
|
||||
|
||||
const qu = require('../utils/qu');
|
||||
const http = require('../utils/http');
|
||||
const slugify = require('../utils/slugify');
|
||||
@@ -31,7 +33,11 @@ function scrapeSceneX(scene) {
|
||||
release.stars = scene.rating;
|
||||
release.tags = scene.tags.map(tag => tag.name);
|
||||
|
||||
release.poster = scene.thumb;
|
||||
if (mime.getType(scene.thumb) === 'image/gif') {
|
||||
release.teaser = scene.thumb;
|
||||
} else {
|
||||
release.poster = scene.thumb;
|
||||
}
|
||||
|
||||
release.channel = slugify(scene.sites[0]?.name, '');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user