웹프로그래밍/Javascript
get Image width and height
jihun202
2020. 7. 8. 10:12
반응형
const getImageSize = (file: File, callback: (width: number, height: number) => void) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = (e) => {
const image = new Image();
image.src = e.target.result as string;
image.onload = function () {
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
callback(this.width, this.height);
};
};
}
반응형