I’m having this problem with both GIMP (for bitmaps) and Inkscape (for vector drawings), so solutions for either are welcome, as I need both anyway.

Many applications have started to crop user-uploaded avatars or other pictures first to a square (by using the smaller edge length) then to a full-sized circle inlaid that square.

To counter this, before uploading I would like to pad the image (resize and possibly move) so that the entire drawing (i.e. anything not background) is contained within the target area.

Example: starting from…

start image

… resize the outer image (not needed here¹, but do as necessary) so that it fits inside the circle…

with circle

… but do not actually add the circle to the image:

desired result

So when I upload this, the drawing (here, the text “foo”) is wholly contained in the circle.

The solution must be precise (i.e. no manual mouse-moving and resizing until it fits) and should be automated / batched. For GIMP this includes scripting; for Inkscape (SVG can be assumed) this may even involve XML editing, XSLT, etc. (but having a solution at all will be worthwhile).

① not needed here because I cheated by drawing the circle first and resizing the drawing to fit; ideally, starting from a nōn-square image would also work

  • What should happen with the edges when for example the image is a square? If some algorithm scales the square down to fit within the circle there will be transparent edges.
    – Wolff
    Dec 13, 2020 at 23:08
  • @Wolff I don’t understand the question. If the starting image is, say, a filled square of foreground colour, then the end result should be a larger square of background colour (or transparency, I can fill that myself) where the initial image is fully contained in the centre.
    – mirabilos
    Dec 13, 2020 at 23:18
  • 1
    I just mean to automate it, you need the program to understand what you want to happen in all cases. I can just see many different cases. If you can live with the "lowest common denominator" you could just find out which percentage to scale a square to fit into a circle with the same diameter as the side of the square, and just use that same scale factor for all images after making sure they fit into a square.
    – Wolff
    Dec 13, 2020 at 23:46
  • But not all drawings extend to the edge of the enclosing rectangle.
    – mirabilos
    Dec 14, 2020 at 1:10
  • Then trim them first, change the canvas to a square and expand the canvas afterwards to get the proper margin. But the more I think about this the more different cases I see. For example if you have some image with a center like this, wouldn't you rather keep the original center like in b than fill the circle like in c? And if you have a square image like this, wouldn't you rather crop the image to the circle like in b than fit the square inside the circle like in c?
    – Wolff
    Dec 14, 2020 at 17:12

1 Answer 1


Possible answer for Gimp:

ofn-enclosing-circle (available here) determines the smallest circle that encloses the shape and does things with it.

enter image description here

Note that on your image it doesn't produce the circle that you expect:

enter image description here

.. but the circle is a tighter fit (294 px vs 300px).

If you look at the Wikipedia article the smallest circle is either defined by a diameter (two points on the shape that are diametrically opposed) or by three points (three points of the shape are on the circle).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.