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

Add new file formats supported by PyMuPDF (epub, svg, bmp, pnm, bpm, ppm) #697

Merged
merged 2 commits into from
Jan 31, 2024

Conversation

deeplow
Copy link
Contributor

@deeplow deeplow commented Jan 30, 2024

(two commits on top of #627) just to get the Qubes support working.

Partially fixes for #660. Missing some files due to limitations 1:

  • PSD - only available from PyMuPDF>=1.23.0 (qubes-fedora is lower)
  • TXT - only available from PyMuPDF>=1.23.7 (qubes-fedora is lower)
  • JXR - PyMuPDF was refusing to due to missing codec 1
  • JPX - Generated test file was rejected by PyMuPDF 2
  • FB2 - Most often cannot be detected by mime type alone 3
  • CBZ - (idem)
  • XPS - (idem)
  • MOBI - (idem)
  • PAM - General version of other file format already included, so I
    decided not to include this extension 0

New test files were generated locally:

  • mobi/epub - generated with calibre's convert-ebook from another
    sample file
  • svg - generated with inkscape from a mix of a default template
    (hexagons) and a logo's PNG file
  • bmp, pnm, bpm, ppm - generated with ImageMagick's 'convert' from
    tests/test_docs/sample-png.png

@deeplow
Copy link
Contributor Author

deeplow commented Jan 30, 2024

I had originally also added support for txt, mobi and psd but I later found those had issues in our various system configurations.

While psd and txt had to do with older PyMuPDF versions on Fedora, mobi was working on Qubes but failing on the container. Basically the mimetype library on Qubes correctly identifies the file format but on container we have another one and it says application/octet-stream :/

@deeplow deeplow changed the title Add new file formats supported by PyMuPDF (epub, mobi svg bmp pnm bpm ppm Add new file formats supported by PyMuPDF (epub, svg, bmp, pnm, bpm, ppm) Jan 31, 2024
Copy link
Contributor

@apyrgio apyrgio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, feel free to merge!

Replaced for clarity over the fact that this conversion is in fact
handled by PyMuPDF.
Partially fix for #660. Missing some files due to limitations [1]:
- PSD - only available from PyMuPDF>=1.23.0 (qubes-fedora is lower)
- TXT - only available from PyMuPDF>=1.23.7 (qubes-fedora is lower)
- JXR - PyMuPDF was refusing to due to missing codec [1]
- JPX - Generated test file was rejected by PyMuPDF [2]
- FB2 - Most often cannot be detected by mime type alone [3]
- CBZ - (idem)
- XPS - (idem)
- MOBI - (idem)
- PAM - General version of other file format already included, so I
  decided not to include this extension [0]

New test files were generated locally:
 - epub - generated with calibre's convert-ebook from another
   sample file
 - svg - generated with inkscape from a mix of a default template
   (hexagons) and a logo's PNG file
 - bmp, pnm, bpm, ppm - generated with ImageMagick's 'convert' from
   tests/test_docs/sample-png.png

[0]: #660 (comment)
[1]: #660 (comment)
[2]: #660 (comment)
[3]: #688
@deeplow deeplow marked this pull request as ready for review January 31, 2024 20:04
@deeplow deeplow merged commit cd99122 into main Jan 31, 2024
50 checks passed
deeplow added a commit to freedomofpress/dangerzone.rocks that referenced this pull request Jan 31, 2024
Formats added to dangerzone version 0.6.0 in [1]

[1]: freedomofpress/dangerzone#697
deeplow added a commit to freedomofpress/dangerzone.rocks that referenced this pull request Feb 26, 2024
Formats added to dangerzone version 0.6.0 in [1]

[1]: freedomofpress/dangerzone#697
@apyrgio apyrgio deleted the 660-pymupdf-formats branch May 22, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants