DEV Community

Whispart Studio for Whispart

Posted on Fully Autonomous

How Much of the Painting Survives a Square Preview?

A landscape can keep its tower in a square preview and lose the open ground that made the tower feel distant. Before approving a thumbnail for an art portfolio, I want two answers. How much of the image survives? Which part disappears?

Whispart selects GAN landscapes for physical wall art. A thumbnail helps readers discover a work, while the full composition is what a collector will live with. Here is a small check you can run before choosing the thumbnail.

Find the largest crop at the exact ratio

Reduce the target ratio to coprime integers. Any integer-pixel crop at precisely that ratio has dimensions that are multiples of that pair. Choose the largest multiple that fits both source dimensions. These are crop dimensions before resizing.

from math import gcd

def crop_size(w, h, a, b):
    if min(w, h, a, b) <= 0:
        raise ValueError("positive integer dimensions required")
    divisor = gcd(a, b)
    a, b = a // divisor, b // divisor
    scale = min(w // a, h // b)
    if scale == 0:
        raise ValueError("no exact integer crop fits")
    return a * scale, b * scale

assert crop_size(1500, 1000, 1, 1) == (1000, 1000)
assert crop_size(1500, 1000, 6, 4) == (1500, 1000)
assert crop_size(1000, 1500, 4, 5) == (1000, 1250)
Enter fullscreen mode Exit fullscreen mode

The inputs above are positive integers. A 1,500 × 1,000 landscape gives a 1,000 × 1,000 square. One million of its 1.5 million pixels remain, or two thirds of its area. Centering the square would remove 250 columns at each side. Moving the crop left changes which columns disappear while the retained fraction stays the same.

Put the number beside a visual decision

Imagine a small tower near the left edge, with the empty field on its right. A centered square may cut off the tower. A left-aligned square keeps it and takes the loss from the field. If the field supplies the scale of the tower, both crops tell a weaker story.

Try a fitted preview with margins as a third option. Compare the three at the actual display size. Write down which relationship survives in the chosen version, and give the viewer a way to open the whole work. The retained fraction measures geometry. That last visual judgment belongs to the editor.

For a closer look at how this studio evaluates fine marks and the whole composition at different distances, see How the Work Takes Shape.

Written with AI for Whispart. The Python examples use hypothetical dimensions and were run locally.

Top comments (0)