Java/ImageIO getting image dimensions without reading the entire file?

try(ImageInputStream in = ImageIO.createImageInputStream(resourceFile)){ final Iterator<ImageReader> readers = ImageIO.getImageReaders(in); if (readers.hasNext()) { ImageReader reader =; try { reader.setInput(in); return new Dimension(reader.getWidth(0), reader.getHeight(0)); } finally { reader.dispose(); } } } Thanks to sfussenegger for the suggestion

CUDA determining threads per block, blocks per grid

In general you want to size your blocks/grid to match your data and simultaneously maximize occupancy, that is, how many threads are active at one time. The major factors influencing occupancy are shared memory usage, register usage, and thread block size. A CUDA enabled GPU has its processing capability split up into SMs (streaming multiprocessors), …

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=””> 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}: ${}<br>`); const …

Read more

What is the difference between getWidth/Height() and getMeasuredWidth/Height() in Android SDK?

As the name suggests the measuredWidth/height is used during measuring and layoutting phase. Let me give an example, A widget is asked to measure itself, The widget says that it wants to be 200px by 200px. This is measuredWidth/height. During the layout phase, i.e. in onLayout method. The method can use the measuredWidth/height of its …

Read more