Skip to content

Commit 77c6e8c

Browse files
Use uuid, it speeds up the call
1 parent 62a6e4c commit 77c6e8c

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
from . import extra
3131
import importlib.util
32+
import uuid
3233

3334
# Set up g_out_log and g_out_message from environment variables.
3435
#
@@ -12543,12 +12544,8 @@ def insert_image(
1254312544
ilst += [i[1] for i in doc.get_page_xobjects(page.number)]
1254412545
ilst += [i[4] for i in doc.get_page_fonts(page.number)]
1254512546
n = "fzImg" # 'pymupdf image'
12546-
i = 0
12547-
_imgname = n + "0" # first name candidate
12548-
while _imgname in ilst:
12549-
i += 1
12550-
_imgname = n + str(i) # try new name
12551-
12547+
# Use a uuid for uniqueness
12548+
_imgname = f"{n}{uuid.uuid4()}"
1255212549
if overlay:
1255312550
page.wrap_contents() # ensure a balanced graphics state
1255412551
digests = doc.InsertedImages

0 commit comments

Comments
 (0)