I wrote this notebook awhile ago to profile a beam with a number of images from a CCD. I added this beam profiling code to a lab utils repo with some example images. This example is not great because the images are not perfectly Gaussian and the beam is not profiled through a waist. Ideally, you would want to do that to get better results.
Here is a totally better way to do the exact same thing for a single image.
I am attaching a zip of my code. The fitting to the beam profile isn't perfect and needs to be fixed. I would write your own code to fit it to the beam