A photo handoff often includes a final image, an intended destination and a sentence such as “make it square.” That is not quite enough information for another person to review the export. A square file may be too small for the destination; a large file may have the wrong aspect ratio. Both checks are useful, but they answer different questions.
This article builds a tiny, local metadata check for that handoff. It does not open images, alter pixels, inspect content or decide whether an edit is visually good. The code is an independent example, not an integration with any photo service. I am associated with Y2K Photo Lab, and AI assistance helped prepare this article. The examples are hypothetical rather than measurements of real photographs.
The handoff contract
Imagine a team preparing a profile image. The person exporting it reports a width and height; the recipient supplies a target width and height. A basic check can report whether the two aspect ratios match and whether either source dimension is smaller than the corresponding target dimension.
Those results should stay separate. An 800 × 400 source and a 400 × 400 target have different ratios even though the source has enough pixels in both dimensions. A 200 × 100 source and a 400 × 200 target have matching ratios, but the source is smaller. Neither result says which crop is aesthetically appropriate or whether the chosen subject will remain visible.
The inputs here are dimensions supplied by a caller. They are not verified against a file. A real application that needs to inspect image files should use an appropriate image library, apply resource limits and test its handling of malformed files. This small example deliberately avoids those responsibilities.
Implement a pure check
Save this function as crop_review.py:
from math import isfinite def review_crop(width, height, target_width, target_height): values = (width, height, target_width, target_height) if any(isinstance(v, bool) or not isinstance(v, (int, float)) or not isfinite(v) or v <= 0 for v in values): raise ValueError("dimensions must be finite positive numbers") ratio_error = abs(width / height - target_width / target_height) return { "ratio_matches": ratio_error < 1e-9, "needs_upscale": width < target_width or height < target_height, "source_ratio": width / height, } The explicit Boolean check matters in Python because bool is a subclass of int. Treating True as a width of one pixel would hide a caller error. The function also rejects zero, negative numbers, infinity and NaN. It accepts positive integers and floats, but many production systems should choose a narrower contract: integer pixels with a documented maximum, for example.
The tolerance is an absolute comparison of ratios, not a universal image-quality threshold. It avoids requiring exact binary floating-point equality, but the right tolerance depends on the application's rules. If dimensions are always integers and exact ratio matching is required, cross multiplication can avoid floating-point comparison entirely. For very large values, consider the limits of the language and the surrounding data format.
Exercise the contract
These simple examples show the two outputs independently:
print(review_crop(800, 800, 400, 400)) # ratio_matches: True, needs_upscale: False print(review_crop(200, 100, 400, 200)) # ratio_matches: True, needs_upscale: True print(review_crop(800, 400, 400, 400)) # ratio_matches: False, needs_upscale: False A matching ratio does not prove that a crop has enough detail, that a face is centered, or that the image is licensed for its intended use. Similarly, the needs_upscale flag does not tell you how an application would resample an image. It only compares the numeric dimensions supplied to the function.
The target dimensions also need context. A service might accept a large upload but generate a smaller thumbnail; another may expect a specific export size. Record whether the target is a minimum, a maximum, or an exact requirement. This example interprets it as a minimum size and a desired ratio. Do not silently use it to validate a maximum-size policy.
Test meaningful boundaries
The following tests use only Python's standard library. Put them beside the function in test_crop_review.py:
import math import unittest from crop_review import review_crop class ReviewTests(unittest.TestCase): def test_exact_square(self): self.assertEqual( review_crop(800, 800, 400, 400), {"ratio_matches": True, "needs_upscale": False, "source_ratio": 1}, ) def test_ratio_and_upscale_are_independent(self): self.assertTrue(review_crop(200, 100, 400, 200)["needs_upscale"]) self.assertFalse(review_crop(800, 400, 400, 400)["ratio_matches"]) def test_invalid(self): for value in (0, -1, True, None, math.inf, math.nan): with self.subTest(value=value), self.assertRaises(ValueError): review_crop(value, 100, 50, 50) if __name__ == "__main__": unittest.main() Run python3 -m unittest -v test_crop_review from the directory containing both files. The three tests pass in the local environment used to prepare this example. They cover the stated examples and a handful of invalid values; they do not establish a complete production test suite. Add tests for the precise tolerance boundary, extremely large dimensions, any chosen upper bounds and the behavior required by your own application.
Keep visual review separate
After the metadata check, a person still needs to inspect the actual output. Compare the original and exported image at the intended display size. Look for a crop that cuts off useful context, texture that obscures a face, or a background that becomes distracting at thumbnail scale. These are visual observations, not properties that the function above can derive from dimensions.
A browser-based y2k photo editor is one optional way to explore early-digital color and texture, compare an edit with the original and crop a picture. Studio adds detailed adjustments and batch editing. Check current features, terms and pricing on the site. Other editors can be used with the same review process; this example does not call the product or claim a built-in API.
Keep the original file, verify that you have permission to use the image, and document the intended audience. A decorative treatment should not be presented as an untouched record. For scientific, medical or other consequential material, follow the relevant image-integrity rules and do not treat a creative filter as evidence.
Make the result useful in a handoff
A small record can contain the source filename, dimensions, destination dimensions, the two flags, the chosen crop and a note about permissions. Avoid including private contact details when they are not needed. If a filename or path is supplied by another user, do not treat it as trusted merely because a dimension check passed.
Most importantly, distinguish what was checked from what remains open. “The supplied dimensions share a ratio and meet the minimum size” is narrower and more useful than “the image is ready.” The next person can then perform the visual, rights and publication checks that this small function intentionally leaves to them.

