Skip to content
Discussion options

You must be logged in to vote

I made a comparison of the 3 methods:
´´´python
doc=fitz.open("adobe.pdf")

def test1():
t0=time.perf_counter()
for page in doc:
irect=page.rect.irect
pixsize= irect.width * irect.height * 3 + 88
t1=time.perf_counter()
return t1-t0

def test2():
t0=time.perf_counter()
for i in range(doc.page_count):
xref=doc.page_xref(i)
mb = doc.xref_get_key(xref, "MediaBox")
if mb[0]!="array":
raise ValueError("no mediabox for page",i)
w, h = mb[1][1:-1].split()[2:]
pixsize = w * h * 3 + 88
t1=time.perf_counter()
return t1-t0

def test3():
t0=time.perf_counter()
for page in doc:
pix=page.get_pixmap()
size=pix.size
t1=time.perf_counter()
return t1-t0


> Note that other than default DPI values need not be co…

Replies: 4 comments 10 replies

Comment options

You must be logged in to vote
1 reply
@JorjMcKie
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@JorjMcKie
Comment options

@JorjMcKie
Comment options

@PasaOpasen
Comment options

@JorjMcKie
Comment options

@JorjMcKie
Comment options

Comment options

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

@PasaOpasen
Comment options

Answer selected by JorjMcKie
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
Converted from issue

This discussion was converted from issue #1893 on August 22, 2022 12:56.