java - Is there any way to find out the extensions of the Images stored in a database as binary data? -


i have product details including product image(binary data) mssql database , store locally on android device image files, don't know type of images. think when we're storing images files extension matters, if matters there way find out image extensions?

thanks , regards.

you can use bitmapfactory.options.outmimetype that. contain string image/png or image/jpg after image decoded.

sample:

inputstream in = getassets().open("image.file"); bitmapfactory.options opts = new bitmapfactory.options(); bitmapfactory.decodestream(in, null, opts); log.d(tag, "mime type: " + opts.outmimetype); 

in case writes in log:

05-31 15:20:34.131: d/test(3803): mime type: image/jpeg


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -