# Why is app.image always nil

**URL:** <https://community.aseprite.org/t/why-is-app-image-always-nil/24384>\
**Category:** Development\
**Created:** [January 17, 2025, 7:54pm UTC](https://community.aseprite.org/t/why-is-app-image-always-nil/24384 "2025-01-17T19:54:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![B0r34li5](https://community.aseprite.org/user_avatar/community.aseprite.org/b0r34li5/32/9161_2.png) [@B0r34li5](https://community.aseprite.org/u/B0r34li5)\
**Post date:** [January 17, 2025, 7:54pm UTC](https://community.aseprite.org/t/why-is-app-image-always-nil/24384/1 "2025-01-17T19:54:22Z")

</div>

I was trying to make a script, when I ran into this issue.

app.image is nil and I don’t know why since I have an image open.

```auto
local image = app.image

if image == nil then
    return app.alert("NO IMAGE IN APP")
end

for it in image:pixels() do
    local pixelValue = it() -- get pixel
    it(pixelValue) -- set pixel
    print(it.x, it.y) -- get pixel x,y coordinates
end

return app.alert("EXECUTED SUCCESSFULLY YAY!")

```

This is all the code.

---

<div class="post-metadata">

**Author:** ![Olga\_Galvanova](https://community.aseprite.org/user_avatar/community.aseprite.org/olga_galvanova/32/3294_2.png) [@Olga\_Galvanova](https://community.aseprite.org/u/Olga_Galvanova)\
**Post date:** [January 17, 2025, 8:48pm UTC](https://community.aseprite.org/t/why-is-app-image-always-nil/24384/2 "2025-01-17T20:48:27Z")

</div>

it works for me in 1.3.9.2  
however, it appears app.image exists only if there is image associated with layer and cel in focus. so, if you have empty layer or cel selected, there is no active image.

---

<div class="post-metadata">

**Author:** ![B0r34li5](https://community.aseprite.org/user_avatar/community.aseprite.org/b0r34li5/32/9161_2.png) [@B0r34li5](https://community.aseprite.org/u/B0r34li5)\
**Post date:** [January 17, 2025, 9:43pm UTC](https://community.aseprite.org/t/why-is-app-image-always-nil/24384/3 "2025-01-17T21:43:06Z")

</div>

This is weird, as there isn’t an empty layer, I will try updating aseprite.
