Getting real dimensions of image in java no matters what its origin is -


i trying actual width , height of png or jpeg image in java via following ways:

bufferedimage image = imageio.read(new bytearrayinputstream(byte [] imagecontent)); image.getwidth(); image.getheight(); 

it works as desired landscape image ( width greater height) portrait automatically rotates image , interchange width , height without flag if rotation has been done.

another approach taken cater issue reading jpeg data directly byte stream:

    while (c3 == 255) {         int marker = is.read();         int len = readint(is,2,true);         if (marker == 192 || marker == 193 || marker == 194) {             is.skip(1);             height = readint(is,2,true);             width = readint(is,2,true);             mimetype = "image/jpeg";             break;         }         is.skip(len - 2);         c3 = is.read(); } 

however above approach works edited images if touched editor, images taken camera directly faces same issue.

pointers library on same highly appreciated.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -