mirror of
https://github.com/directus/directus.git
synced 2026-02-02 10:25:05 -05:00
* Rotate JPG image on upload #4206 * fixes #3949 width/height generated for gif and tif * API hooks for event added for auth.login #4079 * updated doc for api hooks for new auth.login event * Style tweaks * Update docs * Tweak docs some more * Spelling error * Allow non-required flags and pass to hook * SDK - Persistent login refresh fixes #4113 * Fixed #4145 SDK, Token Expired error * Spell check * Docs Spell check * Docs Spell check * Docs Spell check * update docs for sdk-js * To delete all expired session from db on login * corrected the condition for the delete * changed the from Date.now to new date . * Move it inline * fixes issue 4557 for asset quality for thumbnail * asset documentation is updated Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -47,7 +47,7 @@ export class AssetsService {
|
||||
|
||||
const assetFilename =
|
||||
path.basename(file.filename_disk, path.extname(file.filename_disk)) +
|
||||
this.getAssetSuffix(resizeOptions) +
|
||||
this.getAssetSuffix(transformation) +
|
||||
path.extname(file.filename_disk);
|
||||
|
||||
const { exists } = await storage.disk(file.storage).exists(assetFilename);
|
||||
@@ -62,6 +62,9 @@ export class AssetsService {
|
||||
|
||||
const readStream = storage.disk(file.storage).getStream(file.filename_disk, range);
|
||||
const transformer = sharp().rotate().resize(resizeOptions);
|
||||
if (transformation.quality) {
|
||||
transformer.toFormat(type.substring(6), { quality: Number(transformation.quality) });
|
||||
}
|
||||
|
||||
await storage.disk(file.storage).put(assetFilename, readStream.pipe(transformer));
|
||||
|
||||
@@ -89,12 +92,12 @@ export class AssetsService {
|
||||
return resizeOptions;
|
||||
}
|
||||
|
||||
private getAssetSuffix(resizeOptions: ResizeOptions) {
|
||||
if (Object.keys(resizeOptions).length === 0) return '';
|
||||
private getAssetSuffix(transformation: Transformation) {
|
||||
if (Object.keys(transformation).length === 0) return '';
|
||||
|
||||
return (
|
||||
'__' +
|
||||
Object.entries(resizeOptions)
|
||||
Object.entries(transformation)
|
||||
.sort((a, b) => (a[0] > b[0] ? 1 : -1))
|
||||
.map((e) => e.join('_'))
|
||||
.join(',')
|
||||
|
||||
Reference in New Issue
Block a user