ImageMagick isn't necessarily "linked" with GhostScript. It can use gs as a "delegate" (separate program) that converts to and from PostScript, PDF, and EPS. See "config/delegates.xml" in the ImageMagick distribution.
Within ImageMagick's "coders/ps.c", the actual interface looks like this:
It's the same deal with GraphicsMagick; see config/delegates.mgk in the GraphicsMagick distribution. In GM, the interface is
ImageMagick itself claims to be under the Apache-2.0 license and GraphicsMagick itself claims to be under the MIT license.
Now IANAL and TINLA, but I believe that either of these allows you to license your webapp however you wish.
However, if your ImageMagick or GraphicsMagick was built with libgs, then it is definitely linked with Ghostscript, and doesn't use the "delegate" mechanism. Further muddying the waters is the fact that there are both GPL and AGPL plus commercially licensed releases of GhostScript that you (or a downstream user) might use.
Here is the position of Artifax, the owner of Ghostscript:
Artifax licensing information, which includes this:
If your application (including its source code) is not licensed to the
public under the AGPL, you are not authorized under the terms of the
AGPL to ship AGPL Ghostscript or AGPL MuPDF with your application, or
to allow your users to remotely interact with AGPL Ghostscript and
AGPL MuPDF along with your application, if any one of the following is
your application contains a copy of some or all of AGPL Ghostscript or AGPL MuPDF;
your application is derived from, is based on, or constitutes a revision of some or all of AGPL Ghostscript or AGPL MuPDF;
your application includes one or more functions that use some or all of AGPL Ghostscript or AGPL MuPDF.
The first two cases are not true of ImageMagick or GraphicsMagick, but I'm not sure about the last one. You'll need to ask your lawyer.
I can't find anything in the Affero license itself that supports Artifex' position. In fact, it says
This License explicitly affirms your unlimited permission to run the
but if you run the unmodified program via another program such as ImageMagick, Artifex threatens to terminate your license.
The Affero license does say
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your
version supports such interaction) an opportunity to receive the
Corresponding Source of your version by providing access to the
Corresponding Source from a network server at no charge, through some
standard or customary means of facilitating copying of software. This
Corresponding Source shall include the Corresponding Source for any
work covered by version 3 of the GNU General Public License that is
incorporated pursuant to the following paragraph.
but I don't think that paragraph comes into play here, because we are talking about running an unmodified copy of the Affero-licensed GhostScript program.
The question came up on the ImageMagick discourse server a few years ago and the response was "its incumbent upon the user to decide if they are complying with the licenses of the software they use."