Get the displayed size of an image inside an ImageView

the following will work: ih=imageView.getMeasuredHeight();//height of imageView iw=imageView.getMeasuredWidth();//width of imageView iH=imageView.getDrawable().getIntrinsicHeight();//original height of underlying image iW=imageView.getDrawable().getIntrinsicWidth();//original width of underlying image if (ih/iH<=iw/iW) iw=iW*ih/iH;//rescaled width of image within ImageView else ih= iH*iw/iW;//rescaled height of image within ImageView (iw x ih) now represents the actual rescaled (width x height) for the image within the view (in other … Read more

Image size for all screen devices

use directly https://romannurik.github.io/AndroidAssetStudio/ For example, two devices that both report a screen size of normal might have actual screen sizes and aspect ratios that are slightly different when measured by hand. Similarly, two devices that report a screen density of hdpi might have real pixel densities that are slightly different. Android makes these differences abstract … Read more

Check image width and height before upload with Javascript

The file is just a file, you need to create an image like so: var _URL = window.URL || window.webkitURL; $(“#file”).change(function (e) { var file, img; if ((file = this.files[0])) { img = new Image(); var objectUrl = _URL.createObjectURL(file); img.onload = function () { alert(this.width + ” ” + this.height); _URL.revokeObjectURL(objectUrl); }; img.src = objectUrl; … Read more

Get file size, image width and height before upload

Multiple images upload with info data preview Using HTML5 and the File API Example using URL API The images sources will be a URL representing the Blob object <img src=”https://stackoverflow.com/questions/12570834/blob:null/026cceb9-edr4-4281-babb-b56cbf759a3d”> const EL_browse = document.getElementById(‘browse’); const EL_preview = document.getElementById(‘preview’); const readImage = file => { if ( !(/^image\/(png|jpe?g|gif)$/).test(file.type) ) return EL_preview.insertAdjacentHTML(‘beforeend’, `Unsupported format ${file.type}: ${file.name}<br>`); const … Read more