уменьшение картинки

This commit is contained in:
Nastya 2023-07-13 01:14:06 +03:00
parent e20c9a839d
commit c6658411e1
2 changed files with 22 additions and 6 deletions

@ -115,6 +115,12 @@ export default function StartPageSettings({ handleNext }: HandleNext) {
return (
<>
<DropFav
text="a"
sx={{}}
heightImg="100"
widthImg="200"
/>
<Typography variant="h5" sx={{marginTop: "60px"}}>Стартовая страница</Typography>
<Box sx={{
backgroundColor: "white",

@ -13,11 +13,20 @@ interface Props {
export default ({text, sx, heightImg, widthImg}: Props) => {
const theme = useTheme();
const callback = (newFileUri:any) => setData(URL.createObjectURL(newFileUri));
// const callback = (newFileUri:any) => setData(URL.createObjectURL(newFileUri));
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);
};
const resizeImage = (imageFile:any) => {
console.log(imageFile[0])
try {
Resizer.imageFileResizer(
imageFile,
imageFile[0],
150,
150,
"JPEG",
@ -27,15 +36,16 @@ export default ({text, sx, heightImg, widthImg}: Props) => {
);
} catch (err) {
console.log(err);
}}
const handleImageResize = (imgInp:any) => resizeImage(imgInp.files);
}
}
const imgHC = (imgInp:any) => {
const [file] = imgInp.files
if (file.size < 5242880) {
setData(URL.createObjectURL(file))
} else {enqueueSnackbar('Размер картинки слишком велик')}
handleImageResize(file)
console.log(file.height)
resizeImage(imgInp.files)
}