naturalWidth と naturalHeight で取得できました
- document.getElementById("image_id").naturalWidth;
- document.getElementById("image_id").element.naturalHeight;
コード.gs
function doGet() { return HtmlService.createHtmlOutputFromFile("index"); } |
意訳この機能がやること 指定したHTMLファイルを表示する |
index.html
<!DOCTYPE html> <html> <body> <button id="bt">button</button> <br> <img id="source" src="画像URL"> <script> document.getElementById('bt').onclick = getOriginalSize; function getOriginalSize() { var source = document.getElementById('source'); var originalWidth = source.naturalWidth; var originalHeight = source.naturalHeight; alert([originalWidth, originalHeight]); } </script> </body> </html> |
参考
Image naturalWidth Property
https://www.w3schools.com/jsref/prop_img_naturalwidth.asp
Image naturalHeight Property
https://www.w3schools.com/jsref/prop_img_naturalheight.asp
Image naturalWidth Property
https://www.w3schools.com/jsref/prop_img_naturalwidth.asp
Image naturalHeight Property
https://www.w3schools.com/jsref/prop_img_naturalheight.asp