Nguyen  Minh Binh Nguyen Minh Binh - 1 year ago 124
Android Question

How to capture a custom image size with the camera in android?

How to capture an square image in android?
I want to capture an square image (such as 300x300 pixel) by calling Camera through intent in android, how can I do this?

Answer Source

EDIT: This is deprecated since API level 21.

Use the Camera.Size nested class

From the android reference:

Class Overview

The Camera class is used to set image capture settings, start/stop preview, snap pictures, and retrieve frames for encoding for video. This class is a client for the Camera service, which manages the actual camera hardware.

Make sure that the size is supported by the camera (and most probably it won't). If not, take a picture at the closest resolution and crop it or resize it.

Camera myCamera =;
List<Camera.Size> sizes = myCamera.getPArameters().getSupportedPictureSizes();

To learn about camera intents, check these questions already in SO:

Android camera intent

Camera intent android

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download