def update_photo_metadata(): values = {} for k in request.forms.keys(): values[k] = request.forms[k] image_path = values['image_path'] del values['image_path'] path_parts = image_path.split('/') reader.update_exif('/'.join(path_parts[2:]), values) Album(path=os.path.dirname(image_path)).delete_metadata_cache()
def test_write_update_tag_for_image(self): source = os.path.join(config.photo_dir, "boris-1.jpg") temp_file = os.path.join(config.photo_dir, "test_file.jpg") shutil.copyfile(source, temp_file) try: tags = { "comment": "test comment", "keywords": "test,keywords", "title": "test title", "subject": "test subject", "person_in_image": "john doe,jill,john humpheries", } reader.update_exif("test_file.jpg", tags) retrieved_tags = reader.get_exif("test_file.jpg") self.assertDictContainsSubset(tags, retrieved_tags) finally: if os.path.exists(temp_file): os.remove(temp_file)
def test_write_update_tag_for_image(self): source = os.path.join(config.photo_dir, 'boris-1.jpg') temp_file = os.path.join(config.photo_dir, 'test_file.jpg') shutil.copyfile(source, temp_file) try: tags = { 'comment': 'test comment', 'keywords': 'test,keywords', 'title': 'test title', 'subject': 'test subject', 'person_in_image': 'john doe,jill,john humpheries' } reader.update_exif('test_file.jpg', tags) retrieved_tags = reader.get_exif('test_file.jpg') self.assertDictContainsSubset(tags, retrieved_tags) finally: if (os.path.exists(temp_file)): os.remove(temp_file)