  We have generated synthetic images of $\sim$27,000 galaxies from the
IllustrisTNG and the original Illustris hydrodynamic cosmological simulations,
designed to match Pan-STARRS observations of $\log_{10}(M_{\ast}/{\rm
M}_{\odot}) \approx 9.8$-$11.3$ galaxies at $z \approx 0.05$. Most of our
synthetic images were created with the SKIRT radiative transfer code, including
the effects of dust attenuation and scattering, and performing the radiative
transfer directly on the Voronoi mesh used by the simulations themselves. We
have analysed both our synthetic and real Pan-STARRS images with the newly
developed $\tt{statmorph}$ code, which calculates non-parametric morphological
diagnostics -- including the Gini-$M_{20}$ and
concentration-asymmetry-smoothness (CAS) statistics -- and performs
two-dimensional S\'ersic fits. Overall, we find that the optical morphologies
of IllustrisTNG galaxies are in good agreement with observations, and represent
a substantial improvement compared to the original Illustris simulation. In
particular, the locus of the Gini-$M_{20}$ diagram is consistent with that
inferred from observations, while the median trends with stellar mass of all
the morphological, size and shape parameters considered in this work lie within
the $\sim$1$\sigma$ scatter of the observational trends. However, the
IllustrisTNG model has some difficulty with more stringent tests, such as
producing a strong morphology-colour relation. This results in a somewhat
higher fraction of red discs and blue spheroids compared to observations.
Similarly, the morphology-size relation is problematic: while observations show
that discs tend to be larger than spheroids at a fixed stellar mass, such a
trend is not present in IllustrisTNG.
