# Display a grid of dragged and dropped images

**URL:** <https://openrndr.discourse.group/t/display-a-grid-of-dragged-and-dropped-images/805>\
**Category:** Tutorials\
**Created:** [December 2, 2026, 11:35am UTC](https://openrndr.discourse.group/t/display-a-grid-of-dragged-and-dropped-images/805 "2026-12-02T11:35:57Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [December 2, 2026, 11:35am UTC](https://openrndr.discourse.group/t/display-a-grid-of-dragged-and-dropped-images/805/1 "2026-12-02T11:35:57Z")

</div>

![A 4x4 grid of images featuring round things](https://global.discourse-cdn.com/free1/uploads/openrndr/original/2X/5/56e815dcf30cbfadc0b1f88a5dfa8208e6cc8e03.webp)

> **Imports**
>
> ```kotlin
> import org.openrndr.application
> import org.openrndr.draw.ColorBuffer
> import org.openrndr.draw.loadImage
> import org.openrndr.extra.imageFit.FitMethod
> import org.openrndr.extra.imageFit.imageFit
> import org.openrndr.extra.shapes.primitives.grid
> import kotlin.math.ceil
> import kotlin.math.roundToInt
> import kotlin.math.sqrt
> 
> ```

```kotlin
fun main() = application {
    configure {
        width = 1920
        height = 1920
    }
    program {
        val images = mutableListOf<ColorBuffer>()

        extend {
            val side = ceil(sqrt(images.size.toDouble())).roundToInt()
            drawer.bounds.grid(
                side, side, 50.0, 50.0, 20.0, 20.0
            ).flatten().take(images.size).forEachIndexed { i, rect ->
                drawer.imageFit(images[i], rect)
            }
        }

        window.drop.listen { event ->
            event.files.forEach {
                when(File(it).extension.lowercase()) {
                    "jpg", "jpeg", "png" -> images.add(loadImage(it))
                }
            }
        }
    }
}

```

I just started a program and thought this early version might show some interesting things, so sharing it here.

The only thing it does is to react to files dropped onto the program window. You can drop a bunch of files, and it will try to load and display jpg and png images as a grid. That’s it.

I like how simple it is 🙂

---

<div class="post-metadata">

**Author:** ![MoOnThePage](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/moonthepage/32/1001_2.png) [@MoOnThePage](https://openrndr.discourse.group/u/MoOnThePage)\
**Post date:** [December 3, 2026, 7:33pm UTC](https://openrndr.discourse.group/t/display-a-grid-of-dragged-and-dropped-images/805/2 "2026-12-03T19:33:58Z")

</div>

I have been experimenting with the file drop for a while with no success till now, I want to do two things the first one is to drop an image extract the edge of it and animate the drawing process using FFT, the second thing is for my current project that play music at the moment I am playing the music placed inside the directory while I want to be able to drag and drop the music to the application and the application save the files in that directory and name it as a temp playlist. But seeing this I would like to ask you sir would you mind me steal your code and miss with it 😊 also I can’t wait to see what are you cooking with that 👍👍👍

---

<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:** [December 3, 2026, 9:10pm UTC](https://openrndr.discourse.group/t/display-a-grid-of-dragged-and-dropped-images/805/3 "2026-12-03T21:10:38Z")

</div>

No stealing necessary! Any code I post online is for anyone to use 😁

And if you get stuck just ask!

---

<div class="post-metadata">

**Author:** ![MoOnThePage](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/moonthepage/32/1001_2.png) [@MoOnThePage](https://openrndr.discourse.group/u/MoOnThePage)\
**Post date:** [December 3, 2026, 11:51pm UTC](https://openrndr.discourse.group/t/display-a-grid-of-dragged-and-dropped-images/805/4 "2026-12-03T23:51:02Z")

</div>

Too late already stolen 😂😂😂, thank you for sharing the code and thank you for opening the door for asking I tried it and as usual to added some image I have and the think I like is that the more I add the more it keep displaying them in a grid and I can’t wait to see the next one. also after playing with this I got this idea of making a galley with but make it play with music too.

 ![image](https://global.discourse-cdn.com/free1/uploads/openrndr/original/2X/4/48b27ebda4590981ebe89436a3906d4a3edf0a70.jpeg)
