jya-dev / supernote-tool

Unofficial python tool for Supernote
Apache License 2.0
237 stars 26 forks source link

ValueError: not enough image data #25

Closed cwhittl closed 1 year ago

cwhittl commented 1 year ago

Running the code below, trying to make an automated process to use DropBox and also be able to read the notes. `find ../Supernote type f -name ".note" -print0 | while read -d $'\0' file do newFile="${file%.}.pdf"

TODO compare last updated

supernote-tool convert -a -t pdf -a "$file" "$newFile"

done ` It creates one PDF successfully but then I get this error on the others.

Traceback (most recent call last):
  File "/opt/homebrew/bin/supernote-tool", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/supernotelib/cmds/supernote_tool.py", line 203, in main
    args.handler(args)
  File "/opt/homebrew/lib/python3.10/site-packages/supernotelib/cmds/supernote_tool.py", line 96, in subcommand_convert
    data = converter.convert(-1, vectorize, enable_link=use_link) # minus value means converting all pages
  File "/opt/homebrew/lib/python3.10/site-packages/supernotelib/converter.py", line 304, in convert
    imglist = self._create_image_list(converter, page_number)
  File "/opt/homebrew/lib/python3.10/site-packages/supernotelib/converter.py", line 315, in _create_image_list
    img = converter.convert(i)
  File "/opt/homebrew/lib/python3.10/site-packages/supernotelib/converter.py", line 67, in convert
    return self._convert_layered_page(page, self.palette, visibility_overlay)
  File "/opt/homebrew/lib/python3.10/site-packages/supernotelib/converter.py", line 96, in _convert_layered_page
    img = self._create_image_from_decoder(decoder, binary, palette=palette, blank_hint=all_blank)
  File "/opt/homebrew/lib/python3.10/site-packages/supernotelib/converter.py", line 137, in _create_image_from_decoder
    img = Image.frombytes('RGB', size, bitmap)
  File "/opt/homebrew/lib/python3.10/site-packages/PIL/Image.py", line 2969, in frombytes
    im.frombytes(data, decoder_name, args)
  File "/opt/homebrew/lib/python3.10/site-packages/PIL/Image.py", line 830, in frombytes
    raise ValueError(msg)
ValueError: not enough image data

I am running this on a M1 Mac running Ventura and I have a brand new Supernote A6X running the latest version.

Thanks!

jya-dev commented 1 year ago

Hi, I haven't been able to reproduce that phenomenon. If you don't mind, could you share the file causing the error?

If you notice the difference between a file that causes the error and a file that does not, I would be happy if you could let me know. It is my guess that using a custom background may cause that error.

cwhittl commented 1 year ago

The only difference I can see is that the one that converted uses a builtin SuperNote template and one of the ones that didn't uses a custom imported template (loaded through MyStyle folder) I've attached one that converted and one that didn't. Archive.zip

cwhittl commented 1 year ago

Just for further experiments I tried to do png as well and it failed with the same error.