@Girgias Yeah sadly it will become more complicated as there can be doctype declarations too, which is a parser nightmare. I could do it with libxml after all, maybe that's more maintainable, it would require extending the image handling API with something such that other extensions can hook into it. I'm gonna try and see how good or bad it looks, it's hard to tell upfront.