This might sounds somewhat hollow and you're probably already aware of this in a sense but body weight is generally a poor indicator of overall health, and too much fixation on body weight as a primary goal generally will not lead to the most optimal health decisions, being more likely to result in yoyo dieting, focus on immediate results over more sustainable ones and, therefore, can have a counterproductive effect. Far better to use some other metric, ie, caloric intake compared to caloric expenditure (ie, exercise and activity level) as well as making sure you're getting all the right nutrients, etc.
Easier said than done, perhaps, and I know fixation on body weight is very common, especially for women. But just something to consider. Of course, weight gain is a known side effect of many psychiatric medicines, and knowing this won't just switch off the behavioural drives that lead to weight gain. Additionally, I understand that for someone who struggles with body image issues, body weight is a very tangible metric that is very easy to become emotionally attached to, compared to more intangible ones that are harder to emotionally resonate with... so maybe I shouldn't comment, but I guess the idea I'm trying to express is that your weight is likely not nearly as much of an issue as you think it is, but of course I'm sure you know that already.
Other than that I don't have too much to add, except to say that...
We've all thought that at some point I think. Try not to beat yourself up about it.
Good luck to you finding some resolution to your struggles anyway.