Images placed in documents are enhanced based on the context in which the image is used. Context is determined according to document-specific indicators such as nearby text, headings, titles, and tables of content. A generative adversarial network (GAN) modifies the image according to the context to selectively emphasize relevant components of the image, which may include erasing or deleting irrelevant components. Relevant general-purpose images may be retrieved for use in the document and may be selectively enhanced according to usage of the general-purpose image in a given document.