If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


  • 1
    ilvalle  12 years ago

    I've defined the upload field with the options uploadseparate=True, uploadfolder=request.folder+'uploads/pictures'

    It would be nice to integrate automatically this two options, so far I changed the code as follows (is not the best way but it works):

    try:
       img = Image.open(request.folder + 'uploads/pictures/' + image)

    except:
       try:

          splits = image.split('.')
          path = splits[0] + '.' + splits[1] + '/' + splits[2][:2] + '/'
          global_path = request.folder + 'uploads/pictures/' + path + image
          img = Image.open(request.folder + 'uploads/pictures/' + path + image)
       except:

          return image

    [...]

     

    Paolo

    replies (2)
    • mlrichardvezina 11 years ago

      I think need to define uploadfolder with uploadseparate=True can be avoid with retrieve_file_properties Field method : image_dir = current.db.auth_user.image.retrieve_file_properties(image)['path'] img = Image.open(os.path.join(image_dir, image))

    • titogarrido 12 years ago

      Hey Paolo! I have the same problem... are you able to post here the entire code?

Commented on:

In this recipe you will see how to create a custom computation to create a thumbnail to fit centered in a specific box

Hosting graciously provided by:
Python Anywhere