mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
Enabling high quality chroma subsampling for webp by default in the hope of slightly nicer thumbnail quality #558
This commit is contained in:
parent
b8cf00c076
commit
c181bd5fb5
@ -4,11 +4,7 @@ import * as os from 'os';
|
|||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
import {ProjectPath} from '../../ProjectPath';
|
import {ProjectPath} from '../../ProjectPath';
|
||||||
import {Config} from '../../../common/config/private/Config';
|
import {Config} from '../../../common/config/private/Config';
|
||||||
import {
|
import {PhotoWorker, RendererInput, ThumbnailSourceType,} from '../threading/PhotoWorker';
|
||||||
PhotoWorker,
|
|
||||||
RendererInput,
|
|
||||||
ThumbnailSourceType,
|
|
||||||
} from '../threading/PhotoWorker';
|
|
||||||
import {ITaskExecuter, TaskExecuter} from '../threading/TaskExecuter';
|
import {ITaskExecuter, TaskExecuter} from '../threading/TaskExecuter';
|
||||||
import {FaceRegion, PhotoDTO} from '../../../common/entities/PhotoDTO';
|
import {FaceRegion, PhotoDTO} from '../../../common/entities/PhotoDTO';
|
||||||
import {SupportedFormats} from '../../../common/SupportedFormats';
|
import {SupportedFormats} from '../../../common/SupportedFormats';
|
||||||
@ -124,7 +120,7 @@ export class PhotoProcessing {
|
|||||||
return path.join(
|
return path.join(
|
||||||
ProjectPath.TranscodedFolder,
|
ProjectPath.TranscodedFolder,
|
||||||
ProjectPath.getRelativePathToImages(path.dirname(mediaPath)),
|
ProjectPath.getRelativePathToImages(path.dirname(mediaPath)),
|
||||||
file + '_' + size + 'q' + Config.Media.Thumbnail.quality + PhotoProcessing.CONVERTED_EXTENSION
|
file + '_' + size + 'q' + Config.Media.Thumbnail.quality + (Config.Media.Thumbnail.smartSubsample ? 'cs' : '') + PhotoProcessing.CONVERTED_EXTENSION
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,6 +253,7 @@ export class PhotoProcessing {
|
|||||||
makeSquare,
|
makeSquare,
|
||||||
useLanczos3: Config.Media.Thumbnail.useLanczos3,
|
useLanczos3: Config.Media.Thumbnail.useLanczos3,
|
||||||
quality: Config.Media.Thumbnail.quality,
|
quality: Config.Media.Thumbnail.quality,
|
||||||
|
smartSubsample: Config.Media.Thumbnail.smartSubsample,
|
||||||
} as RendererInput;
|
} as RendererInput;
|
||||||
|
|
||||||
const outDir = path.dirname(input.outPath);
|
const outDir = path.dirname(input.outPath);
|
||||||
|
@ -46,6 +46,7 @@ export interface RendererInput {
|
|||||||
outPath: string;
|
outPath: string;
|
||||||
quality: number;
|
quality: number;
|
||||||
useLanczos3: boolean;
|
useLanczos3: boolean;
|
||||||
|
smartSubsample: boolean;
|
||||||
cut?: {
|
cut?: {
|
||||||
left: number;
|
left: number;
|
||||||
top: number;
|
top: number;
|
||||||
@ -162,7 +163,7 @@ export class ImageRendererFactory {
|
|||||||
fit: 'cover',
|
fit: 'cover',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await image.rotate().webp({effort: 6, quality: input.quality}).toFile(input.outPath);
|
await image.rotate().webp({effort: 6, quality: input.quality, smartSubsample: input.smartSubsample}).toFile(input.outPath);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,6 +313,16 @@ export class ServerThumbnailConfig extends ClientThumbnailConfig {
|
|||||||
description: $localize`Between 0-100.`
|
description: $localize`Between 0-100.`
|
||||||
})
|
})
|
||||||
quality = 80;
|
quality = 80;
|
||||||
|
@ConfigProperty({
|
||||||
|
type: 'boolean',
|
||||||
|
tags:
|
||||||
|
{
|
||||||
|
name: $localize`Use chroma subsampling.`,
|
||||||
|
priority: ConfigPriority.underTheHood
|
||||||
|
},
|
||||||
|
description: $localize`Use high quality chroma subsampling in webp. See: https://sharp.pixelplumbing.com/api-output#webp.`
|
||||||
|
})
|
||||||
|
smartSubsample = true;
|
||||||
@ConfigProperty({
|
@ConfigProperty({
|
||||||
type: 'ratio',
|
type: 'ratio',
|
||||||
tags:
|
tags:
|
||||||
|
Loading…
Reference in New Issue
Block a user