How to edit images with Gemini

06-Sep-2025 299
This post looks at how we can edit an image with Gemini and llm.rb. Our plan is to edit an image to be a little silly by adding a cowboy hat into the mix. The llm.rb library supports both image generation (with a prompt) and image editing (also done with a prompt) plus much more that we won’t cover here. Let’s get started 😃 Placeholder We don’t want to offend anybody or cross any red lines, so the first step we will take is to generate a placeholder image on the fly. This will allow us to follow up and edit the image by adding a cowboy hat as mentioned earlier. Let’s generate a single image, and save it to use later:.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle