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

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -