Forums

IMAGE DOWNLOAD

Hello,

first: thank you in advance!

I resize uploaded pictures, and I would like to download into folder.

The upload and save to directory works.

The load of the picture and resize works.

BUT: I can not save into folder.

I tried a lot of version but none of them works.

The main problem:

        AttributeError: 'NoneType' object has no attribute 'save'

The code is:

        img_formate = "." + str(file.filename).split(".")[-1]
        image = "new_picture" + img_formate

        photo.save(os.path.join(app.config['UPLOAD_FOLDER'], image))

I already changed the "image"' for name as well new_pic_jpg or png. Same as the uploaded. "photo" is the resized as well.

How can I solve this?

The variable photo in that code is coming back as None so there is nothing to save. Check back in your code to see why photo may be None

resized_image = original_image.resize((int(original_widthfactor), int(original_heightfactor))) resized_image.save(os.path.join(app.config['UPLOAD_FOLDER'], image)) I tried that way.

  photo = cv2.imread(resized_image,0)
  photo.save(os.path.join(app.config['UPLOAD_FOLDER'], image))

That way also. The path works because I load from there other picture. file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) The save method also works because that works well in code.

I do the same in desktop and works.

Tried in the code change tha name to "\picture.jpg or png" but that does not help.

Do you still get AttributeError or some other error?

Thank you glenn and fjl. That was a mispelling from my side, the site works 100% percent. It fixed and now the code works as well.