# Can you make pictures ("headless" apps) on Windows with OPENRNDR?

**URL:** <https://openrndr.discourse.group/t/can-you-make-pictures-headless-apps-on-windows-with-openrndr/315>\
**Category:** How to?\
**Created:** [January 2, 2022, 1:25pm UTC](https://openrndr.discourse.group/t/can-you-make-pictures-headless-apps-on-windows-with-openrndr/315 "2022-01-02T13:25:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![asf8p9yasdloiughrlkb](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/asf8p9yasdloiughrlkb/32/342_2.png) [@asf8p9yasdloiughrlkb](https://openrndr.discourse.group/u/asf8p9yasdloiughrlkb)\
**Post date:** [January 2, 2022, 1:25pm UTC](https://openrndr.discourse.group/t/can-you-make-pictures-headless-apps-on-windows-with-openrndr/315/1 "2022-01-02T13:25:04Z")

</div>

Hi, I want to move away from p5.js and Paper.js because they are too slow, and just discovered OpenRNDR.

It seems like it is fast, like Processing, with powerful geometric maths available, like Paper.js. But I don’t care about drawing to the screen - I want to create .png or .bmp files on disk.

I see in [Headless applications - OPENRNDR GUIDE](https://guide.openrndr.org/advancedTopics/headlessApplications.html#limitations) this doesn’t seem possible in Windows, which is weird, because even Paper.js can run without a browser on Node.js on any operating system. But since Windows comes with WSL, can I just make pictures there using OpenRNDR? Or does it need some sort of direct hardware path that VMs don’t provide?

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [January 2, 2022, 1:44pm UTC](https://openrndr.discourse.group/t/can-you-make-pictures-headless-apps-on-windows-with-openrndr/315/2 "2022-01-02T13:44:34Z")

</div>

Hi hi, happy new year 🙂

When you originally posted this question in reddit Yvee1 noticed and it produced this discussion in Slack:

- Yvee1: [Reddit - Dive into anything](https://www.reddit.com/r/OPENRNDR/comments/rsq808/can_you_make_pictures_headless_apps_on_windows/)
- edwin: headless on windows. that is a good question
- Yvee1: I wonder if headless is needed for their use case. it seems they just want to output a picture which can be done with e.g. the SingleScreenshot extension right
- edwin: I think there should be an added option to not make a window, run the draw loop once and exit
  - well yes the saving would then be supported by single screenshot or something similar
  - actually single screenshot already does the exiting part for us
  - which is great because I like the minimal amount of scenarios Application has to be aware of

So as I mentioned in reddit, currently

> There’s no need to draw to a visible screen buffer, you can draw to a non visible [RenderTarget](https://guide.openrndr.org/advancedDrawing/renderTargets.html) (that’s like a PGraphics in Processing) and save it.

This should work on Linux, Windows and Mac. If you try and get stuck feel free to ask here.

If what @edwin mentioned above gets implemented, then there would be not even a window appearing but the program just starting, saving something to disk and closing.

The [Headless applications | OPENRNDR GUIDE](https://guide.openrndr.org/advancedTopics/headlessApplications.html#limitations) you linked above currently only works on Linux and is used (afaik) to generate screenshots and videos on GitHub when something gets committed to the repo. This is used to generate documentation media automatically.

BTW. welcome to the forum! 🙂

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [January 2, 2022, 3:27pm UTC](https://openrndr.discourse.group/t/can-you-make-pictures-headless-apps-on-windows-with-openrndr/315/3 "2022-01-02T15:27:39Z")

</div>

```auto
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.isolatedWithTarget
import org.openrndr.draw.renderTarget
import org.openrndr.extensions.Screenshots
import java.io.File
import kotlin.system.exitProcess

/**
 * Example that saves an image to disk and quits
 * See https://guide.openrndr.org/advancedDrawing/renderTargets.html
 */

fun main() = application {
    configure {
        width = 64
        height = 64
        hideWindowDecorations = true
    }

    program {
        val canvas = renderTarget(4000, 4000) {
            colorBuffer()
        }
        drawer.isolatedWithTarget(canvas) {
            clear(ColorRGBa.WHITE)
            stroke = null
            fill = ColorRGBa.PINK
            ortho(canvas)
            circle(canvas.width / 2.0, canvas.height / 2.0, 1000.0)
        }
        canvas.colorBuffer(0).saveToFile(File("/tmp/result.png"), async = false)
        exitProcess(0)
    }
}

```

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [March 14, 2022, 7:11am UTC](https://openrndr.discourse.group/t/can-you-make-pictures-headless-apps-on-windows-with-openrndr/315/4 "2022-03-14T07:11:12Z")

</div>

Alternative approach if one doesn’t mind briefly seeing the result, avoiding the need for a render target.

```kotlin
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extensions.Screenshots
import org.openrndr.extra.noise.Random
import org.openrndr.extra.noise.uniform

fun main() = application {
    program {
        val screenshots = extend(Screenshots()) {
            async = false
            quitAfterScreenshot = true
        }
        extend {
            drawer.clear(ColorRGBa.WHITE)
            drawer.stroke = null
            drawer.circles {
                repeat(20) {
                    fill = if (it % 2 == 0) ColorRGBa.PINK else ColorRGBa.WHITE
                    circle(drawer.bounds.uniform(100.0), Random.int(2, 10) * 10.0)
                }
            }
            screenshots.trigger()
        }
    }
}

```
