image-occlusion-enhanced
image-occlusion-enhanced copied to clipboard
Unaccessible variable & How to change mask path
Checklist
Please replace the space inside the brackets with an x if the following items apply:
- [x] I've verified that I use the latest version of the add-on by redownloading it from AnkiWeb
- [x] I've verified that I use the latest version of Anki by checking at https://apps.ankiweb.net#download
- [x] I've checked if anyone else asked this question before by looking through the issue reports.
Your question
https://github.com/glutanimate/image-occlusion-enhanced/blob/85af2a55d046750c94c8eccff5979029e4fb6817/src/image_occlusion_enhanced/nconvert.py#L229-L241
What does node_id
mean in line 232? Or it is a typo of note_id
?
Done in https://github.com/glutanimate/image-occlusion-enhanced/issues/250#issuecomment-1166434913.
Details
Besides, I'm struggling change the path of mask svg because these svg fill the media directory. However I couldn't get any information. Can you give me some suggestions? I want to put all of them into media/IO_masks
direcotry for instance.
Meanwhile, can the image be put into new directory just like mentioned above? For example media/images
?
Here's my try. However it only save svg into IO_masks
while not saving their path in field, which means the path in field is still <img src='xxx.svg'>
, not <img src='IO_masks/xxx.svg'>
# nconvert.py
def _saveMask(self, mask, note_id, mtype):
"""Write mask to file in media collection"""
logging.debug(
_("!saving %(note_id)s, %(mtype)s"), {"note_id": note_id, "mtype": mtype}
)
mask_filename = os.path.join("IO_masks", "%s-%s.svg" % (note_id, mtype))
mask_path = os.path.join(self._media_path, mask_filename)
mask_data = mask.encode("utf8")
with open(mask_path, "wb") as f:
f.write(mask_data)
return mask_filename
# ngen.py
def _saveMask(self, mask, note_id, mtype):
"""Write mask to file in media collection"""
logging.debug(
_("!saving %(note_id)s, %(mtype)s"), {"note_id": note_id, "mtype": mtype}
)
mask_filename = os.path.join("IO_masks", "%s-%s.svg" % (note_id, mtype))
mask_path = os.path.join(self._media_path, mask_filename)
mask_data = mask.encode("utf8")
with open(mask_path, "wb") as f:
f.write(mask_data)
return mask_filename
By the way, thanks for your charming work!
I've succeeded in changing the directory(includes image & mark svg) through 3e83482.
Closed due to inactivity.