A code image can look good in a slide, but readers cannot easily copy, search, or adapt it. Keep the snippet short and readable in code to image, and provide the code as text or a link when others may need to run it.
Remove secrets, private hostnames, personal paths, and customer data before making the image. Choose a theme with strong contrast and a font large enough for the smallest display. Check line wrapping and the exported image at presentation size. Include the language and enough context to explain the result.
A polished screenshot does not prove the code is valid or safe.