Issue with random picture selection

Hello friends! I am nearing the completion of my app but am running into a problem that leaves me stuck. My goal is to select a random picture from a list of pictures that are saved in a list every time a button is clicked. Then, use @Taifun Taifun image extension to divide the randomly selected picture into 16 slices. I tried a bunch of things but can't figure out how to save the randomly selected picture only to a file and then use that in the "Imagefilename" slot in the extension's chunk block. I truly appreciate the potential help with this!
Here is the block

Do you mean like this ?


(you may need to include the absolute file path to the image file....)

From the documentation

Create chunks of a jpg image file in the ASD - application specific directory.

You might want to provide a Do it result from your image location

use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

@TIMAI2 thank you very much for the answer! Unfortunately that didn't work. It only solves one of my issues. It saves the randomly picked file in the local variable "img" but because it is a local variable i can't retrieve the 16 chunks that are made later after using the TaifunImage extension and I need those files.

@Taifun. Thank you for an awesome extension! I read the docs before. I use your extension in another part of this app and it works beautifully when the image selected isn't a random picture. My difficulty here is to figure out a way to feed the extension the new randomly picked file every time the button is clicked.

the image must be in the ASD... as already suggested


@Taifun Thanks again for the answer. I am not familiar with the ins and out of the ASD. I have the pictures that are randomly selected uploaded in the designer view as media so I assumed they would be in the ASD but I guess that is not how it works? Any hint on how to save pictures to the ASD and then retrieve them randomly will be greatly appreciated.

PS: I tried to do the Do it function and post the result here but when I download the block, the do it box doesn't appear.

It says. "Do it result: abhas-mishra-BD3qGeorAFY-unsplash.jpg---"

You could have shared screenshot here, if using window, Windows logo key + Shift + S

Suggest the following:

  1. Create a directory for your images in the ASD
  2. Get list of your images from the assets(media folder)
  3. Iterate over this list and copy each file to your new folder in the ASD
  4. Get list of your images in your new folder
  5. Select a random image from this list
  6. Chunk that image
  7. Use the Chunk event to return a list of chunked images

You will need to add the File component for folder creation, listing contents and copying files
(or use Taifun's File extension)


@TIMAI2 thank you! I will try that :slight_smile:

alternatively try

  1. Get list of your images from the assets(media folder)
  2. Select a random image from this list and copy it to ASD
  3. Chunk that image
  4. Use the Chunk event to return a list of chunked images



@Taifun @TIMAI2 Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.