Let's say we have a square image of 500x500. We want to use the bottom 500x200 for loyalty stamps.
Suppose we know the max number of images (different for each use), could we lookup that number (we can, let's say it is 10 stamps), divide the width by that number and distribute evenly somhow so it will oook nice?
For example, if
n=5, we get 1 row of 5 stamps (50 by 50px).
n=10, 2 rows of 5 columns,
n=12, 2x6 (33x33px),
n=20 => 2x10 (25x25px)
I can see we can pre-calculate some of the options before writing the stamps on the image in the set locations, but is there a programmatic way of doing this so it always calculates the most economic/best filling amount of space/images?
It's so very versatile that I figured I ask some pros here before doing it the dumb way

Thanks a ton.