Adobe Photoshop provides an Adaptive Wide Angle filter to to correct lens distortions. I really like the intuitive user interface which allows me to just draw a line to fix issues. Is there any free software which has the same feature?
I don’t know of any circular distortion filters that operate on a single drawn line, though that doesn’t mean there isn’t at least one – others here might have suggestions.
If you’re more interested in correcting for lens distortion than in doing it specifically that way, DigiKam (using the standard Showfoto editor, which can be installed separately) and Darktable use the lensfun library to correct for distortion. There’s also a lensfun plugin for GIMP and probably others. They can also use manual adjustments – or if you’re using the lensfun library it’s sometimes enough to select a similar focal length lens from the list.
They correct for distortion across the image, so if the curvature of the buildings in the top right of your second image is a desired effect they won’t create that additional distortion without manual adjustment.
It’s also worth bearing in mind they’ll apply “correction” to the image as opened, so if your working image is cropped (particularly if the centre of the image is no longer the centre of the lens) there might be other adjustments needed.
Usually they’ll read the lens type from EXIF data, so no line or anything else required (unless you’re going for an intentional artistic effect).