Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function imgLoad(filePath){
- const img = new Image();//imgオブジェクトを読み込み
- img.src = filePath;//filePathにはファイルパスを代入
- img.onload = () =>{//img要素の取得は非同期なので注意
- console.log(img.naturalWidth);//画像データの幅
- console.log(img.naturalHeight);//画像データの高さ
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement