1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 12:49:43 +02:00

Set best image quality for all uploads. Closes #114

This commit is contained in:
Maksim Eltyshev 2021-04-13 18:47:56 +05:00
parent 3806d0c6fd
commit ad60517603
4 changed files with 42 additions and 11 deletions

View file

@ -2,13 +2,11 @@ FROM node AS client-builder
WORKDIR /app
COPY client/package.json client/package-lock.json ./
RUN npm install
COPY client .
RUN npm install npm@latest --global && npm run build
RUN npm install npm@latest --global \
&& npm install \
&& npm run build
FROM node:alpine

View file

@ -52,13 +52,22 @@ module.exports = {
if (imageMetadata) {
let cover256Buffer;
if (imageMetadata.height > imageMetadata.width) {
cover256Buffer = await image.resize(256, 320).jpeg().toBuffer();
cover256Buffer = await image
.resize(256, 320)
.jpeg({
quality: 100,
chromaSubsampling: '4:4:4',
})
.toBuffer();
} else {
cover256Buffer = await image
.resize({
width: 256,
})
.jpeg()
.jpeg({
quality: 100,
chromaSubsampling: '4:4:4',
})
.toBuffer();
}

View file

@ -31,8 +31,20 @@ module.exports = {
);
try {
const originalBuffer = await sharp(buffer).jpeg().toBuffer();
const cover336Buffer = await sharp(buffer).resize(336, 200).jpeg().toBuffer();
const originalBuffer = await sharp(buffer)
.jpeg({
quality: 100,
chromaSubsampling: '4:4:4',
})
.toBuffer();
const cover336Buffer = await sharp(buffer)
.resize(336, 200)
.jpeg({
quality: 100,
chromaSubsampling: '4:4:4',
})
.toBuffer();
const dirname = uuid();

View file

@ -31,8 +31,20 @@ module.exports = {
);
try {
const originalBuffer = await sharp(buffer).jpeg().toBuffer();
const square100Buffer = await sharp(buffer).resize(100, 100).jpeg().toBuffer();
const originalBuffer = await sharp(buffer)
.jpeg({
quality: 100,
chromaSubsampling: '4:4:4',
})
.toBuffer();
const square100Buffer = await sharp(buffer)
.resize(100, 100)
.jpeg({
quality: 100,
chromaSubsampling: '4:4:4',
})
.toBuffer();
const dirname = uuid();