Source:
<code>public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) { (new SaneAsyncTask<Void>(SaneAsyncTask.LOW_CONCURRENCY) { @Override public Void performTask() throws Throwable { final int minSize = 64; if (bitmap.getWidth() < minSize || bitmap.getHeight() < minSize) { if (onImageLoadListener != null) { onImageLoadListener.onImageFailed(); } return null; } Thread.currentThread().setPriority(Thread.MAX_PRIORITY - 1); long millis = System.currentTimeMillis(); Bitmap tempbmp; <START> if (bitmap.getWidth() > BITMAP_COPY_WIDTH) { <END> tempbmp = Bitmap.createBitmap(BITMAP_COPY_WIDTH, ((bitmap.getHeight() * BITMAP_COPY_WIDTH) / bitmap.getWidth()), Bitmap.Config.RGB_565); } else { tempbmp = Bitmap.createBitmap(bitmap.getWidth() - (bitmap.getWidth() % 2), bitmap.getHeight(), Bitmap.Config.RGB_565); } Canvas canvas = new Canvas(tempbmp); Paint paint = new Paint(); paint.setColor(Color.BLACK); canvas.drawBitmap(bitmap, 0, 0, paint); FaceDetector fd = new FaceDetector(tempbmp.getWidth(), tempbmp.getHeight(), 1); FaceDetector.Face[] faces = new FaceDetector.Face[1]; PointF facePos = new PointF(); int numFound = fd.findFaces(tempbmp, faces); if (numFound > 0) { faces[0].getMidPoint(facePos); android.util.Log.d(TAG, "Found face at " + facePos.x + ", " + facePos.y); } tempbmp.recycle(); Log.d(TAG, "Face detection took " + (System.currentTimeMillis() - millis) + "ms"); if (onImageLoadListener != null) { onImageLoadListener.onImageLoaded(bitmap, facePos); } return null; } @Override public void onCatch(Throwable caught) { if (onImageLoadListener != null) { onImageLoadListener.onImageFailed(); } } }).execute(); this.setImageBitmap(bitmap); }</code><technical_language>need if/else condition here. create bitmap fixed width proportional height. ok if original bitmap is smaller fixed width; scaled (a uncommon case anyway)</technical_language>

Target:
public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) { (new SaneAsyncTask<Void>(SaneAsyncTask.LOW_CONCURRENCY) { @Override public Void performTask() throws Throwable { final int minSize = 64; if (bitmap.getWidth() < minSize || bitmap.getHeight() < minSize) { if (onImageLoadListener != null) { onImageLoadListener.onImageFailed(); } return null; } Thread.currentThread().setPriority(Thread.MAX_PRIORITY - 1); long millis = System.currentTimeMillis(); Bitmap tempbmp; tempbmp = Bitmap.createBitmap(BITMAP_COPY_WIDTH, ((bitmap.getHeight() * BITMAP_COPY_WIDTH) / bitmap.getWidth()), Bitmap.Config.RGB_565); Canvas canvas = new Canvas(tempbmp); Rect srcRect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); Rect destRect = new Rect(0, 0, BITMAP_COPY_WIDTH, tempbmp.getHeight()); Paint paint = new Paint(); paint.setColor(Color.BLACK); canvas.drawBitmap(bitmap, srcRect, destRect, paint); FaceDetector fd = new FaceDetector(tempbmp.getWidth(), tempbmp.getHeight(), 1); FaceDetector.Face[] faces = new FaceDetector.Face[1]; PointF facePos = new PointF(); int numFound = fd.findFaces(tempbmp, faces); if (numFound > 0) { faces[0].getMidPoint(facePos); facePos.x = (facePos.x * bitmap.getWidth() / BITMAP_COPY_WIDTH); facePos.y = (facePos.y * bitmap.getHeight() / tempbmp.getHeight()); Log.d(TAG, "Found face at " + facePos.x + ", " + facePos.y); } tempbmp.recycle(); Log.d(TAG, "Face detection took " + (System.currentTimeMillis() - millis) + "ms"); if (onImageLoadListener != null) { onImageLoadListener.onImageLoaded(bitmap, facePos); } return null; } @Override public void onCatch(Throwable caught) { if (onImageLoadListener != null) { onImageLoadListener.onImageFailed(); } } }).execute(); this.setImageBitmap(bitmap); }