mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
Auto rotate JPEG images
Signed-off-by: alxnkt <alxnkt@mail.ru>
This commit is contained in:
parent
cd710d34e0
commit
65293fd21c
@ -144,6 +144,19 @@ const SettingsPage = () => {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="col-6">
|
||||
<Inputs
|
||||
label={formatMessage({
|
||||
id: getTrad('settings.form.autoOrientation.label'),
|
||||
})}
|
||||
name="autoOrientation"
|
||||
onChange={handleChange}
|
||||
type="bool"
|
||||
value={modifiedData.autoOrientation}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/*
|
||||
<Divider />
|
||||
|
@ -5,11 +5,13 @@ const initialState = fromJS({
|
||||
initialData: {
|
||||
responsiveDimensions: true,
|
||||
sizeOptimization: true,
|
||||
autoOrientation: false,
|
||||
videoPreview: false,
|
||||
},
|
||||
modifiedData: {
|
||||
responsiveDimensions: true,
|
||||
sizeOptimization: true,
|
||||
autoOrientation: false,
|
||||
videoPreview: false,
|
||||
},
|
||||
});
|
||||
|
@ -64,6 +64,7 @@
|
||||
"settings.form.responsiveDimensions.label": "Enable responsive friendly upload",
|
||||
"settings.form.responsiveDimensions.description": "It automatically generates multiple formats (large, medium, small) of the uploaded asset",
|
||||
"settings.form.sizeOptimization.label": "Enable size optimization (without quality loss)",
|
||||
"settings.form.autoOrientation.label": "Enable auto orientation",
|
||||
"settings.form.videoPreview.label": "Preview",
|
||||
"settings.form.videoPreview.description": "It will generate a six-second preview of the video (GIF)",
|
||||
"settings.section.video.label": "VIDEO",
|
||||
|
@ -8,6 +8,7 @@
|
||||
"control-card.crop": "Кадрирование",
|
||||
"control-card.delete": "Удалить",
|
||||
"control-card.download": "Скачать",
|
||||
"control-card.replace-media": "Заменить ресурс",
|
||||
"control-card.edit": "Редактировать",
|
||||
"control-card.save": "Сохранить",
|
||||
"form.input.label.file-alt": "Альтернативный текст",
|
||||
@ -58,6 +59,7 @@
|
||||
"settings.form.responsiveDimensions.label": "Включить адаптивную загрузку",
|
||||
"settings.form.responsiveDimensions.description": "Будут сгенерированы большое, среднее, маленькое изображение",
|
||||
"settings.form.sizeOptimization.label": "Включить оптимизацию размера (без потери качества)",
|
||||
"settings.form.autoOrientation.label": "Включить автоопределение ориентации",
|
||||
"settings.form.videoPreview.label": "Превью",
|
||||
"settings.form.videoPreview.description": "Будет сгенерировано шестисекундное превью (GIF)",
|
||||
"settings.section.video.label": "ВИДЕО",
|
||||
|
@ -59,15 +59,17 @@ const generateThumbnail = async file => {
|
||||
};
|
||||
|
||||
const optimize = async buffer => {
|
||||
const { sizeOptimization = false } = await strapi.plugins.upload.services.upload.getSettings();
|
||||
const {
|
||||
sizeOptimization = false,
|
||||
autoOrientation = false,
|
||||
} = await strapi.plugins.upload.services.upload.getSettings();
|
||||
|
||||
if (!sizeOptimization) return { buffer };
|
||||
|
||||
if (!(await canBeProccessed(buffer))) {
|
||||
if (!sizeOptimization || !(await canBeProccessed(buffer))) {
|
||||
return { buffer };
|
||||
}
|
||||
|
||||
return sharp(buffer)
|
||||
const sharpInstance = autoOrientation ? sharp(buffer).rotate() : sharp(buffer);
|
||||
return sharpInstance
|
||||
.toBuffer({ resolveWithObject: true })
|
||||
.then(({ data, info }) => ({
|
||||
buffer: data,
|
||||
|
Loading…
x
Reference in New Issue
Block a user