2 ms·
Inscribing something in a circle isn't good enough. Use the image center of mass to really balance icons. Are there any design tools that provide center of mass
by dahart 9y ago
Inscribing something in a circle isn't good enough. Use the image center of mass to really balance icons. Are there any design tools that provide center of mass?
Here's a minimal python/scipy script to measure the image centroid (of a b/w image):
from scipy import ndimage
im = ndimage.imread(args.input)
com = ndimage.measurements.center_of_mass(im)[:2]
size = im.shape[:2]
print("positive x is right, positive y is up")
print("image centroid is offset from image center by x:{0:.1f} pixels by y:{1:.1f} pixels".format(com[1] - size[1]/2, -(com[0] - size[0]/2)))