Images are corrupted when imported and then exported


I’m using anki’s pylib to package some notes in an apkg file (I’ve posted on here before looking for some advice). I have a CSV of notes, which contain references to images in the manner specified in the anki docs, for example one of the fields might be <img src="somelonguuid_a.svg">. All the images are SVGs, and open fine before I process them with Anki.

The script works as follows:

  • Create a Collection object; import the CSV
  • Call .export_anki_package() on the collection object to spit out an apkg.

The only problem is that, when I import the apkg file into anki, maybe 30% of the images are corrupted and fail to display. Most of them are fine, but the ones that are corrupted fail to open in the card browser, in the cards themselves, and when I look at the file itself in all image viewers claim the file is corrupt. If I pass legacy_support=False to export_anki_package() the number of corrupt files seems to go up markedly, to around 75% or so. I have no idea what could be causing this and I’d appreciate any advice.

I can’t think of any reason why that would happen, especially across both importers. When you manually invoke the exporting screen inside Anki, are you able to reproduce the issue? How exactly are the images corrupted, and is it the same ones each time?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.