Putting prompts in an LLM and saying you "created" the image or text thereof is fraud.
Public libraries don‘t sell anything. Also authors and publishers get payed for having their books in the library (how and how much varies by country). Authors and publishers get nothing for having their books put into AI training data. Hence the former is a public service, and the latter is theft.