What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Calculate an image’s aspect ratio by dividing its width by its height, and classify its orientation by comparing those dimensions: wider than tall is landscape, taller than wide is portrait, and equal dimensions are square. For images that contain EXIF orientation metadata, use the dimensions as they will be displayed—not necessarily the dimensions of the stored pixel data—and apply the metadata transform only once.

What aspect ratio and orientation mean

An image’s aspect ratio describes the proportion of its width to its height. Write it as width:height, such as 3:2, or as a decimal obtained by dividing width by height: 3 / 2 = 1.5. These are two ways to express the same proportion.

Orientation is a category based on the dimensions being described:

  • Landscape: width is greater than height.
  • Portrait: height is greater than width.
  • Square: width and height are equal.

This is a dimensional classification, not an assessment of the scene or subject. An image of a standing person can be landscape if its displayed frame is wider than tall.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Calculate the ratio and classify orientation

  1. Read the image width, W, and height, H, from an image decoder or file-inspection library.
  2. Decide whether you need the dimensions of the encoded pixel data or the image’s intended displayed dimensions. For page layouts and user-facing labels, use displayed dimensions.
  3. If required, account for EXIF orientation as described below, exactly once.
  4. Compare the resulting width and height to classify orientation.
  5. Report the ratio as W:H, a reduced integer pair, or the decimal W / H. Label the format you choose.

For example, a displayed image measuring 1200 × 800 pixels is landscape. Its ratio is 1200:800, or 3:2 after reducing both values by their greatest common divisor, 400. As a decimal, the width-to-height ratio is 1.5. A 900 × 1200 image is portrait and has a 3:4 ratio; a 1000 × 1000 image is square and has a 1:1 ratio.

Account for EXIF orientation before deciding

Some JPEG files store pixel data in one orientation and include EXIF metadata instructing compatible software to rotate or mirror it for display. As a result, the encoded width and height can imply a different orientation from the image a person sees. Apple’s UIImage orientation documentation explains that UIImage handles the transform indicated by orientation metadata. Microsoft also documents EXIF orientation support and dimensions after orientation is applied in its imaging API documentation.

A quarter-turn swaps displayed width and height. A mirror operation changes handedness but does not swap them. If an image-processing or UI library has already applied the transform, do not swap the dimensions again. Apple’s Core Image orientation method applies an orientation transform; its transform lookup method provides a transform for an EXIF orientation value.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Choose one dimension convention

  • Encoded-pixel orientation: classify the stored pixel width and height without applying the display transform. This can be useful when reasoning about raw storage or coordinate systems.
  • Displayed orientation: classify the dimensions after honoring the orientation metadata. This is generally the useful convention for display, layout, and user-facing labels.

Make the convention explicit if the distinction matters. Decoder APIs differ: some report raw pixel dimensions, while others report dimensions after orientation has been applied. Check the chosen decoder’s documentation rather than assuming what its width and height mean.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apply the orientation transform once

There are two sound approaches: use a decoder that automatically applies EXIF orientation and then read its resulting dimensions, or read the raw dimensions and orientation value and calculate the transformed dimensions yourself. Do not combine both approaches. Sharp’s autoOrient() documentation says the operation applies the EXIF Orientation transform, including mirroring, and removes the Orientation tag afterward. It considers the EXIF Orientation tag; orientation stored elsewhere, such as an XMP element, remains the consumer’s responsibility.

If your application also uses annotations, detections, or bounding boxes, keep their coordinate system aligned with the transformed image. AWS notes that Rekognition bounding boxes relate to image orientation in its image-orientation guidance. Transforming the image while leaving coordinates in the old frame can place overlays incorrectly.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Automatic workflow in pseudocode

The logic is independent of a particular library, but the decoder’s metadata and dimension semantics are not. This pseudocode describes the decision process; it is not tested implementation code for a specific file format.

read image dimensions and orientation metadata

if displayed dimensions are required:
    apply or account for the display orientation exactly once

if width > height:
    orientation = "landscape"
else if width < height:
    orientation = "portrait"
else:
    orientation = "square"

ratio_pair = width + ":" + height
ratio_decimal = width / height

To reduce the pair to the smallest whole numbers, compute the greatest common divisor (GCD) of width and height, then divide both by it. For example, GCD(1200, 800) is 400, so 1200:800 reduces to 3:2. Keep the unreduced dimensions separately if you also need the original pixel size.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Implementation decisions that prevent incorrect results

Check what the API’s dimensions represent

Determine whether width and height refer to stored pixels or pixels after EXIF orientation. This matters most when a transform can rotate the image by a quarter-turn. Use a single convention throughout a batch or API response; otherwise, identical-looking images can receive inconsistent labels.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Check which metadata the library supports

Confirm whether the decoder reads EXIF orientation and whether it handles metadata in other locations. Sharp’s auto-orientation operation, for example, is documented for the EXIF Orientation tag, not orientation information stored elsewhere. Support can vary by library, version, runtime, and format, so documentation for one API is not a guarantee for every image-processing tool.

Know what happens to metadata after processing

When pixels are transformed, find out whether orientation metadata is retained, updated, or removed. If an image is rotated and its old orientation tag is still applied downstream, it may be displayed with a second transform. Conversely, removing or ignoring metadata without transforming the pixels can leave the image looking wrong.

Keep related coordinates in the same frame

If you rotate or mirror pixels, apply the corresponding coordinate transform to overlays and bounding boxes, or convert coordinates to the displayed frame by another documented method. A correct aspect ratio does not by itself make coordinates correct.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common errors and how to fix them

Symptom Likely cause Fix
A photo looks portrait, but the program labels it landscape. The program compared encoded dimensions and ignored a quarter-turn EXIF orientation. Use the decoder’s displayed dimensions or account for EXIF orientation before comparing width and height.
An image appears rotated the wrong way after processing. The orientation transform was applied twice, or metadata and transformed pixels now disagree. Check whether the decoder already honors EXIF. Apply the transform once, then verify how the output handles its Orientation tag.
A mirrored image is misclassified as portrait or landscape. The code treated a mirror as a dimension swap. Remember that mirroring changes handedness, not width and height; only a quarter-turn swaps the dimensions.
The displayed ratio and the reported ratio disagree. One value uses raw dimensions and another uses oriented dimensions, or the ratio convention is unclear. Use one dimension convention and label the result as a pair, reduced pair, or width-divided-by-height decimal.
Labels or bounding boxes no longer line up after rotation. Image pixels were transformed but coordinates remained in their original frame. Transform coordinates consistently with the image, following the image or vision API’s coordinate semantics.
Different tools disagree about the same file. The tools may use different metadata sources or report pre-transform versus post-transform dimensions. Inspect each tool’s documented behavior and compare both the stored dimensions and the orientation metadata.

Or skip the browser setup

If your workflow starts with a webpage rather than an image file, ScreenshotNeo can return a screenshot or PDF from one GET request. A screenshot is still an image: use its actual returned dimensions and account for metadata if the format and decoder expose any. For capture options and request details, see the ScreenshotNeo documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server provides screenshot and PDF tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month, with no card required.

Practical notes for batch processing

  • Record which dimension convention you use alongside the classification, especially when downstream systems mix decoders.
  • Keep both the raw dimensions and the displayed dimensions when auditability or coordinate mapping matters.
  • Define how ratios are serialized. For example, 3:2 is a reduced pair, while 1.5 is a decimal quotient; downstream consumers should not have to guess.
  • Handle unreadable files and missing or unsupported orientation metadata explicitly in your application. The available sources establish behaviors for named APIs, not universal behavior across all formats.
  • For image resizing or responsive layout decisions, base the calculation on the image dimensions relevant to the rendered result, and do not treat a landscape/portrait label as a substitute for the actual ratio.

Frequently Asked Questions

Does aspect ratio include image resolution?

No. It describes relative width and height, not the total pixel count. Images at different resolutions can share the same ratio.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is a ratio of 1.5 the same as 3:2?

Yes, when the decimal is defined as width divided by height: 3 divided by 2 equals 1.5.

Can an image be square but still have orientation metadata?

Yes. Orientation metadata may specify a transform, but classification depends on the dimensions after the transform; equal width and height remain square after a quarter-turn.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.