Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webp support #209

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ recursive-include examples *.json
recursive-include examples *.md
recursive-include examples *.pdf
recursive-include examples *.png
recursive-include examples *.webp
recursive-include examples *.xml
recursive-include examples *.zip
recursive-include invenio_previewer *.bcmap
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Invenio module for previewing files.
Features:

- File previewing.
- Support for PDF, ZIP, CSV, MARKDOWN, XML, JSON, PNG, JPG and GIF out-of-the-box.
- Support for PDF, ZIP, CSV, MARKDOWN, XML, JSON, PNG, JPG, GIF, and WEBP out-of-the-box.
- Extensible API to create new previewers.

Further documentation available: https://invenio-previewer.readthedocs.io/
Binary file added examples/demo_files/webpfile.webp
Binary file not shown.
3 changes: 2 additions & 1 deletion invenio_previewer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- CSV (using d3.js)
- Markdown (using Mistune library)
- XML and JSON (using Prism.js)
- Simple images (PNG, JPG, GIF)
- Simple images (PNG, JPG, GIF, WEBP)
- Jupyter Notebooks

Invenio-Previewer only provides the front-end layer for displaying previews
Expand Down Expand Up @@ -168,6 +168,7 @@
... 'notebook.ipynb',
... 'jpgfile.jpg',
... 'pngfile.png',
... 'webpfile.webp',
... )

>>> for f in demo_files:
Expand Down
4 changes: 2 additions & 2 deletions invenio_previewer/extensions/simple_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ..proxies import current_previewer

previewable_extensions = ["jpg", "jpeg", "png", "gif"]
previewable_extensions = ["jpg", "jpeg", "png", "gif", "webp"]


def validate(file):
Expand All @@ -25,7 +25,7 @@ def validate(file):

def can_preview(file):
"""Determine if the given file can be previewed."""
supported_extensions = (".jpg", ".jpeg", ".png", ".gif")
supported_extensions = tuple(f".{ext}" for ext in previewable_extensions)
return file.has_extensions(*supported_extensions) and validate(file)


Expand Down