уменьшение картинки
This commit is contained in:
parent
e20c9a839d
commit
c6658411e1
@ -115,6 +115,12 @@ export default function StartPageSettings({ handleNext }: HandleNext) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<DropFav
|
||||||
|
text="a"
|
||||||
|
sx={{}}
|
||||||
|
heightImg="100"
|
||||||
|
widthImg="200"
|
||||||
|
/>
|
||||||
<Typography variant="h5" sx={{marginTop: "60px"}}>Стартовая страница</Typography>
|
<Typography variant="h5" sx={{marginTop: "60px"}}>Стартовая страница</Typography>
|
||||||
<Box sx={{
|
<Box sx={{
|
||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
|
|||||||
@ -13,11 +13,20 @@ interface Props {
|
|||||||
|
|
||||||
export default ({text, sx, heightImg, widthImg}: Props) => {
|
export default ({text, sx, heightImg, widthImg}: Props) => {
|
||||||
const theme = useTheme();
|
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) => {
|
const resizeImage = (imageFile:any) => {
|
||||||
|
console.log(imageFile[0])
|
||||||
try {
|
try {
|
||||||
Resizer.imageFileResizer(
|
Resizer.imageFileResizer(
|
||||||
imageFile,
|
imageFile[0],
|
||||||
150,
|
150,
|
||||||
150,
|
150,
|
||||||
"JPEG",
|
"JPEG",
|
||||||
@ -27,15 +36,16 @@ export default ({text, sx, heightImg, widthImg}: Props) => {
|
|||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}}
|
}
|
||||||
const handleImageResize = (imgInp:any) => resizeImage(imgInp.files);
|
}
|
||||||
|
|
||||||
|
|
||||||
const imgHC = (imgInp:any) => {
|
const imgHC = (imgInp:any) => {
|
||||||
const [file] = imgInp.files
|
const [file] = imgInp.files
|
||||||
if (file.size < 5242880) {
|
if (file.size < 5242880) {
|
||||||
setData(URL.createObjectURL(file))
|
setData(URL.createObjectURL(file))
|
||||||
} else {enqueueSnackbar('Размер картинки слишком велик')}
|
} else {enqueueSnackbar('Размер картинки слишком велик')}
|
||||||
handleImageResize(file)
|
resizeImage(imgInp.files)
|
||||||
console.log(file.height)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user