algoo / preview-generator

generates previews of files with cache management
https://pypi.org/project/preview-generator/
MIT License
235 stars 51 forks source link

Getting error when process .txt file #210

Open danielgoqueiroz opened 3 years ago

danielgoqueiroz commented 3 years ago

When i try generate a preview of some .txt file txt.txt I am getting the following error:

File "doc_thumbnail_preview.py", line 25, in make_thumbnail path_preview = manager.get_jpeg_preview(file_name, width=int(file_width)) File "/home/daniel/.local/lib/python3.6/site-packages/preview_generator/manager.py", line 186, in get_jpeg_preview mimetype=preview_context.mimetype, File "/home/daniel/.local/lib/python3.6/site-packages/preview_generator/preview/builder/document_generic.py", line 88, in build_jpeg_preview with open(file_path, "rb") as _file: File "doc_thumbnail_preview.py", line 48, in make_preview path_preview = manager.get_pdf_preview(file_name) File "/home/daniel/.local/lib/python3.6/site-packages/preview_generator/manager.py", line 217, in get_pdf_preview mimetype=preview_context.mimetype, File "/home/daniel/.local/lib/python3.6/site-packages/preview_generator/preview/builder/document_generic.py", line 140, in build_pdf_preview with open(file_path, "rb") as input_stream: [Thumbnail/Preview-Documento] Não foi possível gerar Thumbnail e Preview do documento '/home/daniel/Documentos/text.txt'

inkhey commented 3 years ago

Hello, Thanks for using preview generator.

Preview-generator does contain an internal mecanism to guess the true mimetype of the file given, It seems the content of you file is wrongly guessed. You can check with manager.get_mimetype(file_name)to obtain the mimetype guessed.

danielgoqueiroz commented 3 years ago

Thanks for the reply, it helped a lot. I think I will use the specific generator for plain / text.

grateful

danielgoqueiroz commented 3 years ago

Hello, would you have what minimum versions of dependencies are needed to work?

:)

danielgoqueiroz commented 3 years ago

Hello my friend, I am here again. I found my problem, it was in the use of "mimetype" in get_file_mimetype () in builder_factory.py. Since I'm using CentOS, it doesn't have 'mimetype', so I needed to install File :: MimeInfo (https://metacpan.org/pod/File::MimeInfo). If you find it interesting you could put it in the documentation.

Thank you

inkhey commented 3 years ago

Thanks for the reply, it helped a lot. I think I will use the specific generator for plain / text.

grateful

You're welcome :smile:

Hello my friend, I am here again. I found my problem, it was in the use of "mimetype" in get_file_mimetype () in builder_factory.py. Since I'm using CentOS, it doesn't have 'mimetype', so I needed to install File :: MimeInfo (https://metacpan.org/pod/File::MimeInfo). If you find it interesting you could put it in the documentation.

Thank you

Hello, it is just a different way to install the same code as we proposed (for debian) by installing package libfile-mimeinfo-perl in readme (https://github.com/algoo/preview-generator#installation) or did we miss something in the install part ? We should probably take some time to be more clear about the system librairies we do use, to ease user who are not running debian. I don't have much time to do this now, but i you find interesting to document such things, you can also make a proposal ;-)

Hello, would you have what minimum versions of dependencies are needed to work?

:)

Unfortunately we do not have such information now. What i can confirm for sure, is that most if not all builders does work on Debian Stretch (old stable), so it's very unlikely that you will have a "too old library", but you may expect issue in the other side. For example, we do not support python 3.9 because of issue related to vtk, as this is a blocking point, this will certainly be solved but not much time to do it now.