It used to be the case a very long time ago that spritesheet size could become a concern because a certain GPU might not support textures that large, you're not likely to have that worry today, since no GPU has supported anything less than 2048x2048 in approximately forever -- it was long enough ago that I honestly can't remember, late 90s at least, I would think. There's no particular advantage to sizing the sprite-sheet smaller or larger, they don't even *have* to be square, or even powers of two anymore (though powers of two remain nice for mip-mapping purposes, if its a concern -- but often isn't in a 2D game). You might have a theoretical concern over wasting texels with big unused areas, but GPU memory is quite large these days and its not likely to cause any actual issues)
Most tools that do what you're talking about tend to take a list of images, tries to pack them in a way that approaches the optimum, and outputs whatever texture size is necessary (possibly rounded up to some hardware alignment boundary, or to the next power of two).
- Power-of-two dimensions are still something nice to have if your sprites can be viewed from oblique angles (e.g. as a texture) or which can be zoomed in and out.
- The least capable hardware you're even remotely likely to interact with supports textures of at least 2K x 2K.
- Textures don't need to be square.