I have a class where in constructor I get a file. This file is jpeg. How I can get resolution this jpeg file in this class?
This is some code from constructor:
public static Bitmap bitmapSizer(File file) {
BitmapFactory.Options options = new BitmapFactory.Options();
Bitmap bitmap = null;
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
options.inDither = true;
options.inPreferredConfig = Bitmap.Config.ARGB_4444;
options.inPurgeable = true;
options.inSampleSize=8;
options.inJustDecodeBounds = false;
You need to move a few lines of code.
First, get the
Optionsobject up:Note the
options.inJustDecodeBounds =trueThis will only read jpg’s header, not the whole image.
Next, decode your file:
After decoding you’ll get the results in: