algoo / preview-generator

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

Bug: preview-generator tries to handle JSON files and fails #300

Closed hrittich closed 1 year ago

hrittich commented 1 year ago

Description and expectations

Handing a file which has the mime type 'application/json' to preview-generator results in preview-generator trying to generate a preview using wand. This, however, fails and an exception of type wand.exceptions.MissingDelegateError is thrown. I would expect that JSON files are not being processed in any way and that an exception of type preview_generator.exception.UnsupportedMimeType is thrown.

How to reproduce

import json
from tempfile import NamedTemporaryFile
from preview_generator.manager import PreviewManager

cache_path = '/tmp/preview_cache'

with NamedTemporaryFile(mode='w+', suffix='.json') as fp:
    json.dump({'foo': 42, 'bar': 99}, fp)

    manager = PreviewManager(cache_path, create_folder= True)
    path_to_preview_image = manager.get_jpeg_preview(fp.name)
    print(path_to_preview_image)

Version information

Haskaris commented 1 year ago

Hello @hrittich Sorry for the delay, the person originally in charge of the project is unfortunately no longer working with Algoo. As the new person in charge of this project, it took me some time to understand the workings of the project.

After quite few researches, I've found that ImageMagick is indeed not processing JSON as an input but only as an output.