- img = picture_xml.image_file()
- try:
- picture.image_file.save(path.basename(picture_xml.image_path), File(img))
- finally:
- img.close()
+ if image_file is not None:
+ img = image_file
+ else:
+ img = picture_xml.image_file()
+
+ picture.image_file.save(path.basename(picture_xml.image_path), File(img))