Mobile Camera Orientation Test
Ever had a portrait photo arrive sideways, or a video call feed flip when you turn your phone? The Mobile Camera Orientation Test shows you exactly why, in real time. Click Start Camera and rotate your phone between portrait and landscape to watch the live Stream Width, Stream Height, and Screen Orientation readouts change, then click Capture This Orientation at each angle to build a side-by-side comparison in the Captured Comparisons list. The selfie camera test online is free to use with no sign-up, and works on both desktop and mobile browsers.
Every developer who has built a camera orientation test knows the frustration: an image looks perfectly upright in the designer, only to appear sideways on the live site, or a live preview renders stretched and distorted on a unit you never anticipated. Understanding exactly how your device, capture hardware, and output panel interact to produce the final image output is the key to eliminating these bugs permanently — whether you are building an Android imaging application, a PWA, or managing photo upload workflows in a platform like Webflow.
What Is Camera Orientation and Why It Matters for Camera Orientation Handling
Camera orientation is one of the most misunderstood concepts in mobile photography and app development. At its core, it describes the relationship between three distinct coordinate systems: the physical orientation of the image sensor mounted inside the unit, the orientation of the output panel the user is looking at, and the photo orientation encoded inside the image file itself — including its image metadata. When these three systems fall out of alignment, the result is a distorted preview, a rotated output, or an orientation mismatch that leaves users confused. Understanding each layer individually is the first step toward writing code — or configuring a platform — that handles all of them correctly. The test your phone camera online is free to use with no sign-up, and works on both desktop and mobile browsers.
Natural Orientation and Display Orientation
Natural orientation is defined as the display orientation when a unit sits in the position it was designed to be held in. For handsets, natural positioning is almost always portrait orientation — a taller-than-wide form factor that fits comfortably in one hand. For laptops and most Chromebooks, natural orientation is landscape: wider than tall, suited to a desk surface. Tablets sit somewhere between the two and can ship in either portrait or landscape as their default. Handset manufacturers design their flagship products with one-handed stability in mind, keeping the lens position at the top and the thumb coverage area at the bottom, which is why portrait vertical mode feels so natural for a smartphone.
Display orientation — sometimes called screen orientation — refers to whether the unit is physically held in a portrait or landscape position at any given moment, and it changes dynamically as you rotate it. It is critically distinct from display rotation, which is the numeric value (in degrees) that the system reports. Apps and developers often conflate these two concepts, which is one of the primary sources of orientation bugs.
Sensor Orientation: How the Camera Sensor Reports Rotation
Formally, sensor orientation is the number of degrees that an output image from the imaging chip must be rotated clockwise to match the natural orientation of the unit. Equivalently, it is the number of degrees the imaging chip itself was rotated counterclockwise before being physically mounted inside the body. Because capture buffers are always landscape-shaped by nature — the imaging chip is a wide rectangle — and because most handsets have a portrait natural orientation, the camera sensor on a typical phone has a camera sensor orientation of 90 or 270 degrees. On a laptop or Chromebook, where the natural orientation is already landscape, the sensor orientation is typically 0 or 180 degrees.
According to Android compatibility requirements (camera orientation 7.5.5), both the front-facing and the rear imaging units must be oriented so that the long dimension aligns with the panel's long dimension. This ensures that the long side of the output buffer always matches the long side of the output panel, which simplifies orientation compensation logic. The back-facing imaging chip is installed on the reverse side of the unit, so when you look at the panel, the clockwise rotation of the chip appears as a counterclockwise shift from the observer's point of view — a subtlety that trips up many developers writing their first imaging application.
Understanding JPEG and Image Orientation Test Behavior Across Platforms
When a cell phone captures a photo, the raw pixel data is always stored as a landscape-format image inside the JPEG file — this is simply how imaging hardware works. To record which way the handset was actually held at the moment of photo capture, the imaging software writes an EXIF orientation attribute into the JPEG's image metadata block. This single integer — one of the 4 orientations: Orientation 0, Orientation 90, Orientation 180, or Orientation 270 — tells any compliant viewer how many degrees clockwise to rotate the pixel data before showing it. All modern web browsers, including Chrome, read this EXIF orientation attribute and rotate the image accordingly, so shots taken in any direction appear correctly oriented when opened directly in a browser or an image viewer. The phone camera flash torch test is free to use with no sign-up, and works on both desktop and mobile browsers.
The problem begins when image processing pipelines strip the EXIF data during photo upload or transcoding. Once the orientation metadata is gone, the browser has no instruction to rotate the pixel buffer and assumes the shot was captured in the normal landscape position — meaning only a horizontally-framed photo will render correctly in photo display, while portrait, flipped-horizontal, and upside-down shots all appear rotated. This is the root cause of the well-documented exif-stripping problem that affects many web publishing platforms and image hosting services. Photo copyright EXIF fields (photo copyright exif) are stripped at the same time, which is an additional concern for photographers.
Display Rotation Values: Orientation 0 Through Orientation 270
Display rotation is formally defined as the counterclockwise rotation of drawn graphics on the panel, which is the opposite of the physical rotation of the unit from its natural orientation. Display rotation values are always multiples of 90 degrees, mapped to the set {0, 90, 180, 270}. The table below shows what these values represent physically and how they correspond to the unit's orientation configuration:
| Display Rotation Value | Physical Device Position | Display Orientation (Phone) | Display Orientation (Laptop) |
|---|---|---|---|
| 0 degrees (Orientation 0) | Upright position / default position | Portrait orientation (portrait vertical mode) | Landscape orientation (normal landscape position) |
| 90 degrees (Orientation 90) | Rotated 90° counterclockwise | Landscape mode | Portrait mode |
| 180 degrees (Orientation 180) | Upside-down (inverted portrait) | Reverse-portrait / inverted portrait | Reverse-landscape / flipped-horizontal landscape |
| 270 degrees (Orientation 270) | Rotated 90° clockwise | Reverse-landscape | Reverse-portrait |
Note that Display#getRotation() from the Android interface returns the counterclockwise rotation, while OrientationEventListener#onOrientationChanged(int) returns the clockwise rotation — opposite conventions that must be handled carefully in your code. The device orientation event in the browser interface (window.DeviceOrientationEvent) exposes orientation data across the x axis, y axis, and z axis, enabling chrome orientation detection and orientation tracking in three-dimensional space for PWAs and web apps.
Live Camera Orientation Image Orientation Testing: Experiment Results Across Devices
A structured image orientation experiment was conducted using a Samsung Galaxy handset photographed in all 4 orientations: landscape (0°), portrait (90°), flipped-horizontal landscape (180°), and upside-down portrait (270°). The same four images were then tested across three different pipeline configurations to observe photo orientation behavior at each stage.
Image Output Size by Camera and Viewfinder Size Comparison
Before examining orientation behavior, it is important to understand that different imaging units produce different output dimensions. The viewfinder size shown to the user in a shooting application is typically smaller than the actual capture resolution, and the preview aspect ratio must be chosen carefully to avoid a distorted preview. The following comparison table documents observed behavior for a handset versus a laptop in the same orientation experiment:
| Device Type | Natural Orientation | Sensor Orientation Value | Display Rotation | Correction Needed | Image Output Behavior |
|---|---|---|---|---|---|
| Phone (e.g. Samsung Galaxy) | Portrait orientation | 90° | 0° (upright) | 90° clockwise rotation | Correctly oriented if EXIF intact; horizontally-framed output if EXIF stripped |
| Phone | Portrait orientation | 90° | 90° (landscape mode) | 0° (no additional correction) | Wide-format output correctly sized |
| Laptop | Landscape orientation | 0° | 0° | None | Correctly oriented regardless of EXIF |
| Tablet | Landscape or portrait (varies) | 0° or 90° | Varies | Depends on tablet orientation configuration | Inconsistent without explicit handling |
The viewfinder aspect ratio — the ratio of viewfinder width to viewfinder height — must always match the preview aspect ratio of the source buffer. When they diverge, you get a stretched preview or a clipped preview, both of which degrade the user experience. The ideal approach is to select a preview size whose long dimension aligns with the panel's long dimension, consistent with the long dimension alignment rule enforced by the Android imaging compatibility definition.
Image Upload Experiment: Landscape Image, Portrait Image, and CMS Pipeline
In the handle camera orientations experiment, the same JPEG was uploaded three ways, revealing dramatically different image orientation behavior at each stage:
- Direct external host (Google Drive images): The images were uploaded to Google Drive and served directly. Because no image processing or transcoding occurred, the original EXIF orientation attribute was preserved. All modern web browsers — including Chrome — read the EXIF data and showed all four images in their correct, upright orientation on photo display. This baseline confirmed that the original photo data was correctly oriented before any platform touched it.
- Platform asset upload (Webflow assets and Webflow content system): The same four images were uploaded to Webflow assets and embedded using both an image component in the Webflow visual editor and a content-system-bound rich text block. In the Webflow editor and visual editor, the images appeared correctly oriented. However, on the live site, the EXIF data was stripped during responsive image generation, causing the browser to assume all images were captured in landscape mode. The result: only the wide-format landscape image appeared correctly oriented on web images; the portrait shot, flipped-horizontal frame, and upside-down frame were all image rotated incorrectly. The same problem was observed in content-system images embedded in a rich text block.
- Webflow assets with responsive images disabled: When the responsive image setting was turned off — implementing a disable responsive images approach using the key combination CTRL+SHIFT+O (Windows) or CMD+SHIFT+O (Mac), accessible by selecting the visual component or right-click settings on an embedded image — the full-size version was served without stripping. With responsive image disabled, EXIF data was preserved and all four images showed correctly oriented on the live site.
Note: This behavior is now inconsistent. Regenerating responsive images with CTRL+SHIFT+I and republishing corrects some of the asset-stored images, but not all of them. If you observe some images flipping back after a republish, force-regenerate and check each image component individually. This inconsistency appears to be a race condition in the responsive image size variants generation pipeline.
For images embedded inside a rich text block in the Webflow visual editor, right-click the image and choose Settings, then apply CTRL+SHIFT+O to expose the image compression and responsive image setting for that specific image component. For content-system-bound rich text content, check whether the Webflow editor exposes the same control — this remains an untested edge case for visual components versus editor-managed content.
How to Calculate and Correct Camera Orientation Programmatically: Image Orientation Experiment Formulas
When handling orientations in an Android imaging application built with the camera2 framework, correcting for both sensor orientation and display rotation requires a precise calculation. The general formula for the back-facing unit is:
correctionAngle = sensorOrientation - displayRotationFor a front-facing unit, display rotation acts in the opposite direction relative to the panel, so the formula becomes:
correctionAngle = sensorOrientation + displayRotationWhen using the camera2 framework's capture request, you pass this value as JPEG_ORIENTATION to instruct the encoder how many degrees to rotate the output image clockwise. This is how you rotate the output buffers by the correct amount to produce a correctly oriented JPEG. The OrientationEventListener provides the clockwise rotation, while Display#getRotation() provides the counterclockwise value — be careful not to mix the two conventions. Setting JPEG_ORIENTATION in the capture request is distinct from rotating the preview; the former affects the image file, while the latter affects the live preview rendering.
Worked Numeric Example: Aspect Ratio Constraint Logic
Suppose your activity (viewfinder) has a 9:16 aspect ratio (portrait layout on a handset) and your imaging source buffer has a 3:4 aspect ratio. To decide which dimension to constrain when fitting the preview into the viewfinder:
- Calculate the activity ratio: aspectRatioActivity = (9)/(16) = 0.5625
- Calculate the source ratio: aspectRatioSource = (3)/(4) = 0.75
- Apply the condition: Since aspectRatioActivity ≤ aspectRatioSource, the activity is narrower relative to the source.
- Constrain by width: Set the viewfinder width equal to the activity width, then derive the viewfinder height: viewfinderWidth = activityWidth viewfinderHeight = fracactivityWidthaspectRatioSource
This ensures the viewfinder aspect ratio matches the source dimensions exactly, preventing image distortion or a stretched preview. The viewfinder height and viewfinder width derived this way will always produce a correctly proportioned preview layout. The source dimensions — sourceWidth and sourceHeight — are the authoritative reference for all scaling calculations.
Worked Device Example: Phone in Landscape Mode
Consider a handset with a portrait natural orientation. The imaging chip is mounted with a sensor orientation of 90°. The user rotates the handset 90° counterclockwise into landscape mode, so the display rotation is now 90°. Walking through the correction:
- Known values:
sensorOrientation= 90°,displayRotation= 90° - Apply the formula for a rear-facing unit: correctionAngle = 90° - 90° = 0°
- Interpretation: No additional rotation of the output buffer is needed. The chip's counterclockwise offset and the display rotation cancel each other out, and the image buffer rotation results in a correctly oriented output.
SurfaceView: Simpler Orientation Handling with Automatic Buffer Rotation
The SurfaceView approach is generally recommended for previews when you do not need to process or animate the preview buffer in real time. The Android platform automatically rotates output buffers to match the display orientation of the unit, accounting for both sensor orientation and display rotation internally. This means the preview buffer visible to the user is always portrait when the panel is portrait, and wide-format when the panel is landscape — the platform handles the image buffer rotation for you.
Your primary responsibility when using SurfaceView is ensuring the viewfinder aspect ratio matches the source buffer's aspect ratio exactly. A mismatch produces a distorted preview. The AutoFitSurfaceView class from the Android camera2 samples (available on GitHub) overrides SurfaceView to handle mismatched aspect ratios using a center-crop strategy: it scales the source buffer up until it fills the viewfinder in both dimensions, then clips the overflow using the parent layout params (a RelativeLayout or LinearLayout — note that ConstraintLayout may resize child views rather than clip them, breaking the intended center-crop effect and causing scaled preview artifacts). This output buffer scaling approach maximizes display real estate without distorting the preview aspect ratio.
One important caveat: display rotation alone does not determine the orientation of the source buffer seen by SurfaceView. You must also account for the unit's natural orientation. A laptop orientation differs fundamentally from a handset orientation even at the same display rotation value.
TextureView: Manual Layout for Full Preview Control
The TextureView approach gives you maximum control over the preview rendering but requires significantly more work. Unlike SurfaceView, the Android platform only compensates for sensor orientation when using TextureView — it does not handle display rotations automatically. That responsibility falls entirely on your code. The recommended three-step process avoids the pitfalls of matrix-based approaches (which fail on naturally-landscape units like Chromebooks) and works reliably across Android versions:
- 1. Set the size of the TextureView to be identical to the preview size chosen. If the preview size chosen is
previewWidth × previewHeight, callSurfaceTexture#setDefaultBufferSize(previewWidth, previewHeight)when configuring your capture session, and callView#setLayoutParamsto set the TextureView dimensions topreviewWidth × previewHeightbefore calling the buffer size method. Failing to call layout params first introduces a race condition where TextureView invokes the buffer size call with its own measured (incorrect) dimensions. Use the params method with an appropriateViewGroupcontainer, whether that is aConstraintLayout,RelativeLayout, orLinearLayout. - 2. Scale the potentially stretched TextureView back to the original dimensions of the preview. Because a handset's natural orientation is portrait but the TextureView was set to a landscape-shaped size (
previewWidth × previewHeightwhere previewWidth > previewHeight), the preview appears stretched. Fix this by computing source dimensions and calling the scale methods:- If the natural orientation is portrait or upside-down portrait (sensor orientation is 90 or 270 degrees), then
sourceWidth = previewHeightandsourceHeight = previewWidth. - If the natural orientation is landscape or flipped-horizontal landscape (sensor orientation is 0 or 180 degrees), then
sourceWidth = previewWidthandsourceHeight = previewHeight. - Apply:
setScaleX(sourceWidth / previewWidth)andsetScaleY(sourceHeight / previewHeight).
- If the natural orientation is portrait or upside-down portrait (sensor orientation is 90 or 270 degrees), then
- 3. Rotate the preview by
displayRotationcounterclockwise to compensate for the display rotation. BecauseView#setRotation(float)performs clockwise rotation, pass the negative value:setRotation(-displayRotation). This final step corrects the preview rotation and produces a correctly oriented, scaled preview with no distortion.
The PreviewView component from CameraX in Android Jetpack automates the TextureView layout steps above via its internal PreviewCorrector logic, making it the recommended approach for new imaging application development. The surface buffer size and the coordinate mapping are managed internally, reducing the risk of a stretched preview or incorrect correction on unusual hardware configurations. If you have previously used a raw coordinate-mapping approach for TextureView in your code, note that this method incorrectly assumes a sensor orientation of 90 or 270 degrees and will produce a distorted preview on a naturally-landscape unit such as a Chromebook. Migrating to the three-step process or to CameraX's PreviewView resolves this issue and improves Android 10 support.
Practical Use Cases for Orientation Testing: Handling Camera Orientations in Real Apps
Running a thorough camera orientation test surfaces a surprisingly wide range of edge cases, many of which only appear on specific hardware types or in specific use scenarios. Understanding these scenarios helps you prioritize which orientations to test and which fixes to implement first.
- Video calling apps: Vertical videos and horizontal videos must both render correctly in the remote participant's view. A photo orientation bug that shows a sideways face is immediately noticeable and erodes trust. Both front-facing and rear-facing units must be tested independently, as display rotation acts on the image buffers in opposite directions for each.
- Document scanners: Users capture documents in landscape mode to capture the full width, then switch to portrait mode for receipts. An orientation indicator in the UI helps users confirm correct orientation, but the underlying image data must also encode the correct rotation for downstream OCR processing.
- AR and VR overlays: Augmented reality and virtual reality experiences use the
DeviceOrientationEventJavaScript event (or the equivalent native hardware access on Android) to track tilt directions, compass headings, and axis rotation in three-dimensional space. The x axis, y axis, and z axis values exposed by thedeviceorientation eventandwindow.DeviceOrientationEventpower interactive games, navigation apps, and spatial detection features. These experiences break completely if handset orientation or imaging chip rotation is not correctly mapped to the coordinate system expected by the AR/VR framework. - Web publishing and content-system image uploads: As demonstrated in the image orientation experiment above, uploaded images that pass through a responsive image pipeline may have their EXIF data stripped, affecting photo display of web images. Developers building content management tools — whether in Webflow, a custom platform, or another system — must test every image upload path: direct asset upload, content-system-bound rich text, and images in a visual component. Enable the responsive image setting only when you can verify that EXIF orientation is preserved in all responsive image size variants including the full-size version.
- Platform-specific quirks: Android imaging applications using the camera2 framework must handle the orientation mismatch between the chip's natural orientation and the current display rotation. iOS manages EXIF orientation differently — the OS applies orientation correction before handing pixel data to the application in many cases, which can create subtle differences when the same code is ported. Browser orientation detection via the DeviceOrientation interface requires hardware access permissions that modern browsers gate behind a user gesture, adding an orientation demo step to any PWA that uses motion detection or a gyroscope and accelerometer.
Note: When testing with a front-facing unit, remember that the correction formula reverses the sign of the display rotation component. A bug that only surfaces on the front-facing unit in landscape mode is a common oversight in camera orientation testing, particularly on tablet and laptop configurations where the natural orientation assumptions differ from handsets.
The key takeaways from comprehensive orientation testing: always treat natural orientation, sensor orientation, and display rotation as three independent variables. Never hard-code assumptions about any of them. Test on at least one handset, one tablet, and one laptop or Chromebook to cover both portrait and landscape natural orientations. And always verify behavior with both a rear-facing and a front-facing unit, since the orientation compensation logic differs between them.
Reference Code, Tools, and Documentation for the Camera Orientation Test
The following quick-reference table maps display rotation values to the correction formulas needed for both SurfaceView and TextureView, for a rear-facing unit with a sensor orientation of 90° (typical phone camera):
| Display Rotation Degrees | sensorOrientation − displayRotation (Rear Camera) | SurfaceView Action | TextureView setRotation() Value |
|---|---|---|---|
| 0° | 90° − 0° = 90° | Platform handles automatically | setRotation(0) |
| 90° | 90° − 90° = 0° | Platform handles automatically | setRotation(-90) |
| 180° | 90° − 180° = −90° | Platform handles automatically | setRotation(-180) |
| 270° | 90° − 270° = −180° | Platform handles automatically | setRotation(-270) |
A condensed code sample showing the three-step TextureView orientation correction using the camera2 framework:
// Step 1: Set TextureView size to match preview size (previewWidth x previewHeight)
textureView.setLayoutParams(new ViewGroup.LayoutParams(previewWidth, previewHeight));
surfaceTexture.setDefaultBufferSize(previewWidth, previewHeight);
// Step 2: Compute source dimensions and scale back to correct aspect ratio
// For portrait/reverse-portrait natural orientation (sensorOrientation = 90 or 270):
int sourceWidth = previewHeight;
int sourceHeight = previewWidth;
textureView.setScaleX((float) sourceWidth / previewWidth);
textureView.setScaleY((float) sourceHeight / previewHeight);
// Step 3: Rotate the preview by displayRotation counterclockwise
textureView.setRotation(-displayRotation);
// For JPEG capture: set JPEG_ORIENTATION in the capture request
// (rear camera: sensorOrientation - displayRotation)
int jpegOrientation = (sensorOrientation - displayRotation + 360) % 360;
captureRequestBuilder.set(CaptureRequest.JPEG_ORIENTATION, jpegOrientation);
Key variables used above:
sensorOrientation— retrieved fromCameraCharacteristics.SENSOR_ORIENTATIONdisplayRotation— retrieved fromDisplay#getRotation()(returns counterclockwise degrees)aspectRatioActivityandaspectRatioSource— computed as width divided by height for the activity and source buffer respectivelysetLayoutParams,setScaleX,setScaleY,setRotation—Viewmethods for layout and transformationsetDefaultBufferSize—SurfaceTexturemethod to configure the preview buffer sizejpeg_orientation— the capture request key used to encode clockwise rotation in the output JPEG
For browser and PWA developers, access orientation data via the DeviceOrientation interface. The window.DeviceOrientationEvent fires continuously as the user rotates their hardware, exposing tilt directions, compass headings, and axis rotation values (x axis, y axis, z axis). You can use these real-time values to drive advanced interactive experiences in navigation apps, interactive games, and augmented reality UIs. Refer to the MDN documentation for DeviceOrientation event for full browser support details and the correct way to request access to hardware sensors in Safari on iOS (which requires an explicit permission prompt). The DeviceOrientation interface is also the foundation for orientation demo implementations in PWAs that support homescreen install.
For Webflow users encountering the EXIF-stripping problem during web publishing:
- Access the responsive image setting using CTRL+SHIFT+O (Windows) or CMD+SHIFT+O (Mac) — this key combination reveals the setting for any selected image component or visual element, implementing a responsive image disabled state for that asset.
- To force-regenerate responsive images after a fix, use CTRL+SHIFT+I to trigger the regeneration process, then republish to apply the changes.
- For images hosted in a content-system-bound rich text block, use right-click settings on the embedded image to access the same control. Note that this may not be available in the Webflow editor for content-system images — use the visual editor instead.
- If you need to preserve photo copyright EXIF fields or image metadata containing orientation data, always verify behavior on the live site (not just in the editor) using the browser in Chrome with DevTools open.
Camera orientation handling is a deep topic that spans mobile photography, web development, image compression workflows, Android app development, and responsive design. Whether you are debugging image flipping on a live site, implementing correct orientation compensation in a camera2 framework capture session, or building advanced interactive experiences powered by the DeviceOrientation JavaScript event, the principles remain consistent: understand which coordinate system each value lives in, apply the correction formula for your specific hardware and platform, and test across a representative range of units — handsets, tablets, laptops, and Chromebooks — in both portrait and landscape modes.
Frequently Asked Questions
- What is camera sensor orientation and why does it matter?
- Camera sensor orientation is the physical angle at which the image sensor is mounted inside the device. Most smartphone rear cameras are mounted at 90°, meaning the raw image is rotated compared to what you see on screen. Apps must account for this offset to display and save images correctly, otherwise photos appear sideways or upside-down.
- How do I calculate the corrected rotation for my camera app?
- For a rear-facing camera, the corrected rotation is typically (sensorOrientation - displayRotation + 360) % 360. For a front-facing camera, mirroring is involved, so it becomes (sensorOrientation + displayRotation) % 360. This calculator applies those formulas automatically based on your inputs.
- What is EXIF orientation and which tag value should I use?
- EXIF orientation is metadata embedded in a JPEG file that tells image viewers how to rotate or flip the image for correct display. Tag values range from 1 to 8, where 1 means no rotation needed, 3 means 180°, 6 means 90° CW, and 8 means 270° CW. Many platforms strip EXIF data on upload, which can cause images to appear incorrectly rotated.
- Why do images from mobile phones sometimes appear rotated on websites or in apps?
- Phone cameras embed orientation data in EXIF metadata rather than rotating the actual pixel data. When platforms like web browsers, CMS tools, or social networks strip EXIF data during upload or processing, the raw (unrotated) image is displayed, causing it to appear sideways or inverted. This is a known issue with services like Webflow's asset pipeline.
- How should I size my camera viewfinder to avoid black bars?
- You should compare the aspect ratio of the camera output to the aspect ratio of your viewfinder container. If they don't match, scale the viewfinder to fill one dimension while maintaining the camera's aspect ratio. For example, if the camera outputs 4:3 and your screen is 16:9, you'll need to letterbox or crop to avoid distortion.
- What is the difference between display rotation and sensor orientation?
- Sensor orientation is a fixed hardware property — it doesn't change when you rotate your phone. Display rotation is dynamic and changes as you tilt the device. Your app must combine both values at runtime to determine the final rotation needed to produce a correctly oriented image or preview.
- Does a front-facing (selfie) camera need different orientation handling?
- Yes. Front cameras are mirrored horizontally relative to rear cameras, which affects rotation math. The corrected rotation formula changes, and you may also need to apply a horizontal flip transform to the preview or saved image so selfies appear naturally (not mirrored left-right).
- Which orientations are typically taken with a phone camera?
- The four standard orientations are 0° (landscape), 90° (portrait — most common for phone photos), 180° (inverted landscape), and 270° (inverted portrait). Camera apps should handle all four to ensure images are saved and displayed correctly regardless of how the user holds the device when taking a photo.