Welcome to the Pythonista Community Forums!

Pythonista is a Python programming environment for iOS. To learn more, head over to the Pythonista Website.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Twitter
Load .pngs from folder (Without using the image library)
  • Is it possible to load images from a folder in the Documents directory for the app? I tried sync'd a folder of 8 .pngs over via DropboxSync and attempted to modify the Cards example to load those images instead of the image library ones. I could not get it to load the images...I always ended up with blank cards.

    The images were 512x512 .pngs. I made a new images list that used os.path.listdir to make a list of the images in the folder. I tried load_image_file as well as load_image, I tried giving it the full path to the images, the relative path to the images, just the image name and the file name without the .png file extension.

    Nothing seemed to work. Suggestions are welcome!

    Nate
  • This is just a guess, but one gotcha of loading custom images from files or PIL images is that it only works from the moment the setup method is called. Otherwise, the image cache will be cleared before you can use the images.

    So basically: Make sure that you call load_image_file from the setup method.
  • It seemed to not possible to use an already used imported picture, what worked is this: put it into your photoroll, copy and import, now it works again
  • Hah, nice to see you in here Nate

    - frogor
  • it is impossible for now. so we just have to use c# image library to help us. but i have a big hope for the future.
  • @nate, is it possible to post some code into a gist so that we can all look at what you are trying to do.

    @omz, I did have the use-it-or-lose-it problem that you mentioned with PIL images. I found that I could preserve images if I added them to a scene.layer (myLayer.image = myPilGeneratedImage).