Skip to content

What is the filetype value should I use in fitz.open()? #1593

Answered by JorjMcKie
Augus1999 asked this question in Q&A
Discussion options

You must be logged in to vote

Update on handling wrong file extensions with fitz.open:

  1. For non-image file types only, specify argument filetype.
  2. For supported image files a wrong file extension is no problem: they will always be opened and handled correctly.
    • But the extension must still be one of the supported images. E.g. there is no way to make a PNG file work as a document via fitz.open("file.data", filetype="png"). This case can only be solved by putting the image in memory.
  3. For files in memory, both open formats are accepted (whether or not image): fitz.open("type", memory) and fitz.open(stream=memory, filetype="type").

The behavior for making Pixmap objects is more relaxed: any filename will be accepted and…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@Augus1999
Comment options

@JorjMcKie
Comment options

@JorjMcKie
Comment options

Comment options

You must be logged in to vote
2 replies
@Augus1999
Comment options

@JorjMcKie
Comment options

Answer selected by Augus1999
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants