How to import jpeg images to Codea

I am a new Codea “developper”, What is the syntax for importing an image to a frame on Codea? and if so
1- what kind of extensions could be used ?
2- is it possible to perform a diaporama ?

Thanks in advance.

I’m pretty sure that ln is the default for any application submitted to the apple store, not sure if other extensions like jpeg and co. Are accepted in codea but the developer default for iTunes apps is .png – don’t quote me on this


You can import images by typing “sprite()” in the code editor, and tapping the highlighted portion on the parentheses.

This will bring up the sprite picker, which will allow you to render images from your photo library, Documents, Dropbox, or built-in art packs.

It worked perfectly as expected, Thanks a lot.
Now what about performing à mapped image
I am about to program à course for my students in whome iI havé curves and at any portion related explanations are givin With possible links to web pages. I am about to put the curves as background images, to delineate portions on m’y curves and by searching using image.get the color I will get m’y maps. is there an other issue?

It is possible to access only a pixel? for example to print its value:

i = “Documents:Beach”

if I do this, an error appear:
eror: error: [string"–firstproject…" ]: attempt to call method ‘get’ (a nil value), someone can help me please ?

.@agustin_t: That won’t work. Examine your code a little more closely. You are assigning the string “Documents:Beach” to ‘i’, and then attempting to call a member method ‘get’ on it, which does not exist for string types.

What you need to do is create an image and copy the contents of the “Document:Beach” sprite into it, so you can get the pixel data from it. Here’s an example using the Codea icon from the Cargo Bot spritepack:

-- get the size of the sprite
local iw, ih = spriteSize("Cargo Bot:Codea Icon");
-- create an image with the same size
local img = image(iw, ih);
-- set our image to be the context, and draw the sprite into it
sprite("Cargo Bot:Codea Icon", iw/2, ih/2);
-- fetch and print the pixel value at 100, 100
local r, g, b, a = img:get(100, 100)
print(r, g, b, a)

Hello letaief;

I used the integration with DropBox and the function class “sprite” for call the image when you write sprite(… this call the repository.


“You can import images by typing “sprite()” in the code editor, and tapping the highlighted portion on the parentheses.”

It would be awesome if this were actually written into the inline docs! I searched forever to find out how to import images.

.@TomAuger it’s actually in the Getting Started section. I will think about putting it into the inline docs as well — they don’t lend themselves to images, though, which is a better way to explain this concept.

Hi @letaief and welcome,

On a sidenote, If you dont need to work the image, you can just use

 image = readImage("Documents:myImage")

You can then display it using sprite(image)