feat: add cover selection workflow and docker profiles
This commit is contained in:
@@ -80,6 +80,23 @@ const cropImage = async (file, normalizedConfig) => {
|
||||
return { blob, url };
|
||||
};
|
||||
|
||||
const buildCropResult = (imageMeta, blob, url) => ({
|
||||
id: imageMeta.id,
|
||||
filename: imageMeta.file?.name || imageMeta.filename,
|
||||
blob,
|
||||
url,
|
||||
order: imageMeta.order,
|
||||
});
|
||||
|
||||
export const cropSingleImage = async (image, config) => {
|
||||
if (!config || !config.imageWidth) {
|
||||
throw new Error('Kapak için geçerli bir crop ayarı bulunamadı.');
|
||||
}
|
||||
const normalized = normalizeCropConfig(config);
|
||||
const { blob, url } = await cropImage(image.file, normalized);
|
||||
return buildCropResult(image, blob, url);
|
||||
};
|
||||
|
||||
export const applyCropToImages = async (images, config) => {
|
||||
if (!images?.length) {
|
||||
throw new Error('Önce görsel yüklemelisin.');
|
||||
@@ -91,13 +108,7 @@ export const applyCropToImages = async (images, config) => {
|
||||
const results = [];
|
||||
for (const image of images) {
|
||||
const { blob, url } = await cropImage(image.file, normalized);
|
||||
results.push({
|
||||
id: image.id,
|
||||
filename: image.file.name,
|
||||
blob,
|
||||
url,
|
||||
order: image.order,
|
||||
});
|
||||
results.push(buildCropResult(image, blob, url));
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user