Is it possible to load 400 photos of total size 85MB on android mode?

Is it possible to load 400 photos of total size 85 MB on android mode?
The maximum number of photos I have managed to load is 90 pictures of total size 20 MB.
If I load more I get “FATAL EXCEPTION: Animation Thread” .
I have read similiar topics about the heap size and this error message and I have changed the heap size in AndroidManifest.xml "android:largeHeap=“true” (before that I could load only 45 images).
I want to play 4 small videos (8sec) and as there is a problem with video on android mode my only solution right now (deadline of 3 days) is to load the pictures sequentially.
I have tested on two android devices with similiar results (nexus 7 quad core, 1GB RAM, MLS quad core, 1GB RAM).
Thanks in advance

as for size limit: android standard app has to be <100mo (though there is a workaround for this limit); yet, for loading 85 Mo of images you have to do that outside of your main ui thread. As for videos i dont understand your question: i am now publishing an app with GooglePlaystore which has 10 videos 3 min long…

1 Like

What format and dimensions are the images? Bear in mind compressed disk space usage can be far lower than uncompressed in-memory pixel data!

1 Like

Thank you both for your replies!
Let me clarify for the video.
They asked me to build a very simple android application like a website.
20 pages, written in 4 languages. The user just scrolls the pages.
A button in every page - triggers a 9 sec video according to the language (so they are 4 videos of 9 sec). Nothing serious.
I thought it would be very easy and then I read about the lack of native support video in android mode.

I have read the past two days all of your topics about android mode and the video.
but since I don’t have any java knowledge, just basic processing, I cannot figure out how to play 4 videos (I am struggling with the Conrad’s posted code under your instructions - at first, the canvas appears over the video -
and I am trying to find a safer solution like playing the four video as jpeg sequences.
So can you please give me a hint about how to load the images outside of the main UI thread?
Also, you mention the ketai library for video playing as an easy solution. Can you give me a hint about how can I do that - because I can’t find any relevant video function inside ketai library.

The images are 1280 X 800 jpg - their initial size was approximately 1 MB and through Photoshop, the final size of each photo is up to 250 KB. Your observation is very interesting! - so you mean that the compression I did through Photoshop, is not a good workaround in order to prevent the "“FATAL EXCEPTION: Animation Thread” error. Because I wondering why I could not load more images even though I have reduced their size. So only if I reduce their resolution I can load more images.


Is main thread void setup()?

PImage[] img = new PImage[100];

void setup() {
for(int i=0; i<90; i++){
img[i] = loadImage(nf(i, 1) + “.jpg”);

void draw() {
image(img[85], 0, 0);

i am now working && must reply very quickly:

  • yes, here you are on the main ui thread and android does not accept to block it; so you have to create another thread for loading your images; try to do that onStart() which is before setup(). Yet, are you sure that you need your 100 images since the beginning?? what do you intend to do with them??? Are they displayed all together??? - If not, there are probably other solutions…
    -as for the videos, i am absolutely sure that the code that i have given in my posts on the old forum is working and without Ketai (that i dont use).The main idea is to create a surfaceView on the top and put the video on it, when created. If you dont , your video is displayed (using mediaPlayer) but it is not visible, you can only hear the sound. another question is the video format: if you can download them and read them straming, mp4 is a good choice; if hey are inside your assets use 3gp format.
1 Like

@akenaton thank you again! You are a lifesaver!

So besides onStart(), maybe I have to load/unload the pictures when the app is running.
I thought that this was not a good practice especially when I will have a different picture every 1/frameRate. Ok this could save my app at the finish!
If not I will give one more try to your posted code
(even though I don t understand why you think is so simple : ).

@Yorgos the compression you did in Photoshop is only relevant to disk usage. Once loaded, a 1280x800 image will use 1280x800 = 1024000 pixels. Each pixel is probably an int, so 4 bytes per pixel = 4096000 bytes. So, just under 4MB per image.

1 Like

Now I understand! Because I was so curious why the size in MB of the photos didn’t affect the result. Thank you for your time @neilcsmith !

Showing one image per frame… Have you consider stitching all the iamges together and make a video of them?

For video in Android mode, please check shedMusic's post HERE

Last but not least, ketai lib does not provide any video features. There are other libraries but I am afraid they have not been updated and it is very likely they are out of synch with Processing Android’s latest changes. ShedMusic’s or akenaton’s posts is the way to go. If stuck, provide some code in form of a mcve with some relevant details.


1 Like


is it some kind of slide show ? - In this case perhaps you dont have to load all the images together but (as in a viewPager) only some of them, let us say 3 by 3, depending of your framerate.

At first, I want to thank you all for your interest! Yesterday I found myself in an extremely unpleasant situation. But your quick responses have shown me the right direction. The first mistake I made was that I tried to create a short video by reading an array .@akenaton help to understand that this is silly as it kills the memory.

Also, @neilcsmith prevent me from compress, again and again, the photos till I find the optimum size. It’s pointless

So, I created the most basic video player.
Please forgive me if this is very easy for you. I believe that will help someone with the basic understanding of processing, like me, who wants an immediate solution for playing some small videos through a sequence of images.

String[] imgName = new String[180];

int indx;

void setup() {

for(int i=0; i<180; i++){

imgName[i] = “name” + nf(i, 1) + “.jpg”;

void draw(){

PImage img_load = loadImage(imgName[indx]);
image(img_load, 0, 0);

@kfrajer I will take a look at shedMusic’. Thanks again