Problems with moving an image file to the asd

Hello,
I want to use the Taifun Image Extension to crop an image. To manipulate the image, it must be in the application specific directory.
However, I have issues moving a file to this location. Trying different possibilities I found online, I either get the error message, no such file could be found (when using Anke's tutorial or Taifun's file extension) or just a crash (when using the regular file component).

This is what I did using @Taifun 's extension:
blocks

This is what I did for @Anke 's extension:

And this is what I did with the regular blocks:

If somebody could help me with any of these solutions, this would be greatly appreciated.

1 Like

Where is the original image in Image1.Picture (full file path - show this in a label), how did it get there (was it created by the app or some other app), and what type of image file is it (jpg/png/other) ?

3 Likes

To cut a long story short, post the aia or a test aia.

3 Likes

This is the aia with all methods included:
Bildbeschnitt2 (1).aia (137.6 KB)

The file name (according to the Label) just "[Picturename].jpg" (without a slash at the start). I don't really know where exactly it lies.

Which Android version are you testing on?
Note: My guide was made before the nb188 release.

2 Likes

It is in your Assets (Media), where you put it !! :slight_smile:

2 Likes

And do not hard-code the ASD (packageName):

file:///storage/emulated/0/Android/data/appinventor.ai_informatikprojekt.Bildbeschnitt2/files/image1.jpg

2 Likes

You cannot move files from the assets, you have to copy them.

1 Like

Try the Copy method from the file component together with the correct scope Asset
http://ai2.appinventor.mit.edu/reference/components/storage.html#File.Scope

Taifun

1 Like

Thank you!. The method appears to work (the app finds the path and doesn't throw an error message), but the image disappears when switching file place, although I changed the canvas background image accordingly.

Is the "/image1.png" path still wrong (not the asd)?

1 Like

Thanks, that fixes the issue that the image doesn't appear, but a NullPointer Exception when trying to get the size of the image ("attempt to invoke virtual method "int android.graphics.Bitmap.getWidth() on a null object reference")

It really helps if you show your relevant blocks, without them it is difficult to see what you are trying to achieve.

Of course, it doesn't work, because /image.jpg already redirects to the ASD with this ext.
Try this:

2 Likes

Thank you! Sorry, I'm kind of new to this and didn't understand the file system fully.

1 Like

See also here:

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