You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/recipes-images.rst
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ The script works as a command line tool which expects the filename being supplie
24
24
doc = pymupdf.open(fname) # open document
25
25
for page in doc: # iterate through the pages
26
26
pix = page.get_pixmap() # render page to an image
27
-
pix.save("page-%i.png" % page.number) # store image as a PNG
27
+
pix.save(f"page-{page.number}.png") # store image as a PNG
28
28
29
29
The script directory will now contain PNG image files named *page-0.png*, *page-1.png*, etc. Pictures have the dimension of their pages with width and height rounded to integers, e.g. 595 x 842 pixels for an A4 portrait sized page. They will have a resolution of 96 dpi in x and y dimension and have no transparency. You can change all that -- for how to do this, read the next sections.
30
30
@@ -525,8 +525,8 @@ This script creates an approximate image of it as a PNG, by going down to one-pi
525
525
t1 = time.perf_counter()
526
526
pm.save("sierpinski-punch.png")
527
527
t2 = time.perf_counter()
528
-
print ("%g sec to create / fill the pixmap" % round(t1-t0,3))
529
-
print ("%g sec to save the image" % round(t2-t1,3))
528
+
print (f"{round(t1-t0,3)} sec to create / fill the pixmap")
0 commit comments