Skip to content
Discussion options

You must be logged in to vote

Ah, interesting: I found the reason I think.
MuPDF caches images as much as it can and in the course of this remembers page pixmaps. So to force making a new pixmap, the cache must be emptied.
Then MuPDF will actually re-render the page. The following snippet produces correct before and after pixmaps:

import fitz

doc = fitz.open("sample3.pdf")
page = doc[0]
pix = page.get_pixmap()
pix.save("0before.png")
page.replace_image(11, filename="newimg.png")
fitz.Tools().store_shrink(100)  # empty 100% of the cache
pix = page.get_pixmap()
pix.save("1after.png")

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

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

Comment options

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

@foranuj
Comment options

@foranuj
Comment options

@JorjMcKie
Comment options

Answer selected by foranuj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolved fixed / implemented / answered
2 participants