нарезка фавиконок-18штук
This commit is contained in:
parent
c6658411e1
commit
679b56d59d
@ -14,30 +14,176 @@ interface Props {
|
||||
export default ({text, sx, heightImg, widthImg}: Props) => {
|
||||
const theme = useTheme();
|
||||
// const callback = (newFileUri:any) => setData(URL.createObjectURL(newFileUri));
|
||||
const imageFavicon = [
|
||||
{
|
||||
maxWidth: 16,
|
||||
maxHeight: 16,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 32,
|
||||
maxHeight: 32,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 48,
|
||||
maxHeight: 48,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 76,
|
||||
maxHeight: 76,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 96,
|
||||
maxHeight: 96,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 120,
|
||||
maxHeight: 120,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 128,
|
||||
maxHeight: 128,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 144,
|
||||
maxHeight: 144,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 152,
|
||||
maxHeight: 152,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 167,
|
||||
maxHeight: 167,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 180,
|
||||
maxHeight: 180,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 192,
|
||||
maxHeight: 192,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 196,
|
||||
maxHeight: 196,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 228,
|
||||
maxHeight: 288,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 256,
|
||||
maxHeight: 256,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 300,
|
||||
maxHeight: 300,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 384,
|
||||
maxHeight: 384,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
maxWidth: 512,
|
||||
maxHeight: 512,
|
||||
compressFormat: "PNG",
|
||||
quality: 100,
|
||||
rotation: 0
|
||||
}
|
||||
]
|
||||
const callback = (uri:any) => {
|
||||
var link = document.createElement('a');
|
||||
link.href = uri;
|
||||
link.download = 'Download.jpg';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
// link.download = 'Download.jpg';
|
||||
// document.body.appendChild(link);
|
||||
// link.click();
|
||||
// document.body.removeChild(link);
|
||||
console.log(link)
|
||||
};
|
||||
const resizeImage = (imageFile:any) => {
|
||||
console.log(imageFile[0])
|
||||
try {
|
||||
Resizer.imageFileResizer(
|
||||
imageFile[0],
|
||||
150,
|
||||
150,
|
||||
"JPEG",
|
||||
100,
|
||||
0,
|
||||
callback,
|
||||
);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
// imageFavicon.forEach((obj) => {
|
||||
// try {
|
||||
// Resizer.imageFileResizer(
|
||||
// imageFile[0],
|
||||
// obj.maxWidth,
|
||||
// obj.maxHeight,
|
||||
// obj.compressFormat,
|
||||
// obj.quality,
|
||||
// obj.rotation,
|
||||
// callback,
|
||||
// );
|
||||
// } catch (err) {
|
||||
// console.log(err);
|
||||
// }
|
||||
// })
|
||||
|
||||
// const resizeImage = (imageFile:any) => {
|
||||
// console.log(imageFile[0])
|
||||
// try {
|
||||
// Resizer.imageFileResizer(
|
||||
// imageFile[0],
|
||||
// 150,
|
||||
// 150,
|
||||
// "PNG",
|
||||
// 100,
|
||||
// 0,
|
||||
// callback,
|
||||
// );
|
||||
// } catch (err) {
|
||||
// console.log(err);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
const imgHC = (imgInp:any) => {
|
||||
@ -45,7 +191,21 @@ export default ({text, sx, heightImg, widthImg}: Props) => {
|
||||
if (file.size < 5242880) {
|
||||
setData(URL.createObjectURL(file))
|
||||
} else {enqueueSnackbar('Размер картинки слишком велик')}
|
||||
resizeImage(imgInp.files)
|
||||
imageFavicon.forEach(obj => {
|
||||
try {
|
||||
Resizer.imageFileResizer(
|
||||
[file][0],
|
||||
obj.maxWidth,
|
||||
obj.maxHeight,
|
||||
obj.compressFormat,
|
||||
obj.quality,
|
||||
obj.rotation,
|
||||
callback,
|
||||
);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user