 ##  [Create great graphics with Nushell and Gemini 3](/index.php/node/142) 

    *Submitted by Lennart on Thu, 11 Dec 2025 - 09:28*  

  ![coffee](/sites/default/files/styles/wide/public/2025-12/coffee.png.webp?itok=bkbDzWk7)

 

Imagine being able to create graphics in all kinds of popular formats.

Directly from the command line!

I know, that is not the dream of everyone. But then again, you really should try the command line with Nushell.

So many things can be done faster and more consistently that way.

Anyway, here is a small Nushell module I made to work with Google's Gemini 3 pro image preview model. (Google, you gotta come up with a shorter name.)

```
export def main [
        file: string = output.png
        --aspectratio (-a): string@aspectRatios = "1:1"
        --imagesize (-i): string@imageSizes
] {
        let prompt = ( 'CREATE AN IMAGE' + ': ' + $in )
        let payload = ( {
                contents: [
                        { parts: [ { text: $prompt } ] }
                ],
                generationConfig: { 
                        responseModalities: [ IMAGE ],
                        imageConfig: { aspectRatio: $aspectratio, imageSize: $imagesize }
                }
        } )
        let response = ( http post
                        --content-type application/json
                        --full
                        https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContent?key=REDACTED
                        $payload ) | collect
        ($response).body.candidates.content.parts.0.inlineData.data.0
        | decode base64 | save --force $file
}

def imageSizes [] {
        [
                1K
                2K
                4K
        ]
}

def aspectRatios [] {
        [
                { value: "1:1", description: "Square format commonly used for social media posts (e.g., Instagram grid)."}
                { value: "3:2", description: "Standard format for many DSLR cameras and some laptops."}
                { value: "2:3", description: "Vertical orientation for professional portrait photography."}
                { value: "3:4", description: "Vertical screen layout for older tablets and portrait-oriented mobile apps."}
                { value: "4:3", description: "Traditional standard for older TVs, monitors, and some tablets."}
                { value: "4:5", description: "Common vertical format for social media feeds (e.g., Instagram portrait posts)."}
                { value: "5:4", description: "Historically used in large-format photography; less common in modern use."}
                { value: "9:16", description: "Vertical for smartphones and video platforms (TikTok, Instagram Stories, YouTube Shorts)."}
                { value: "16:9", description: "The universal standard for HDTV, monitors, and online video content (widescreen)."}
                { value: "21:9", description: "Ultra-widescreen cinematic format for specific movies and specialized ultrawide monitors."}
        ]
}

```

Then when I am in the command line I can simply do:

```
'motivational about coffee' | gemima -a 16:9

```

And it will return an image saved as output.png

One very useful thing here is the autocomplete for aspect ratios. When I press tab after the `-a` flag, the descriptions show up. That way I can select the correct one for whatever task I am currently solving.

Have a nice day!



### Tags

- [nushell](/index.php/taxonomy/term/3)