Measuring the diameter of a circle in ImageMagick
If you have an image (or crop of an image) that contains just a circle against a solid background of a contrasting color, you can measure its diameter with the ImageMagick command line tools.
Let's generate an image to test it:
That generates this image:
What are the dimensions of that circle? Run this command:
You get this output:
If the numbers on the sides of the
x are not within 1px of one another, change the value of
fuzz, marked in blue in the code above. If it is a lossless image format such as PNG or GIF, make it 0%. If it's a JPEG, try increasing it. Once they are within one pixel, you have identified the circle's diameter: in this case, 245 pixels.
That is because, internally, you have created this trimmed image: