You get original image with Bitmap myBitmap = BitmapFactory.decodeFile(fname)
.
Integer scaleValue;
Integer scaleHeight = desiredMaxPixelHeight/myBitmap.getHeight();
Integer scaleWidth = desiredMaxPixelWidth/myBitmap.getWidth();
if (scaleHeight < 1 && scaleWidth < 1) scaleValue = 1;
else if (scaleHeight > scaleWidth) scaleValue = scaleHeight;
else scaleValue = scaleWidth;
Bitmap scaledBitmap = Bitmap.createScaledBitmap(myBitmap, myBitmap.getHeight()/scaleValue, myBitmap.getWidth()/scaleValue, false);
Scaling logic can be done better, but point is that you can check info about original bitmap and then create new scaled one with Bitmap.createScaledBitmap(oldBitmap,sizeX,sizeY,false)