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
In the output_images function, if multiple images exist on a single page in the PDF, some images are skipped entirely due to a logic issue.
Cause:
The issue occurs because the code deletes a value at the index from the img_rects list during forward iteration. This deletion shrinks the list, causing the iteration to skip over subsequent elements that haven't yet been processed.
Example:
For example, if img_rects initially contains: parms.img_rects = [image1, image2, image3]
When image1 is processed and deleted, the list becomes: parms.img_rects = [image2, image3]
The next iteration starts at index 1, skipping image2 entirely.
Proposed Fix:
Iterate Backwards - Modify the loop to iterate backward over the list, which ensures that deleting an element doesn’t affect the indices of unprocessed elements:
for i in range(len(parms.img_rects) - 1, -1, -1):
img_rect = parms.img_rects[i]
# Process image...
del parms.img_rects[i]
Seemed to solve the issue for me, however images were then in backwards order so I had to reverse the list.
The text was updated successfully, but these errors were encountered:
Saw this issue was already reported - had missed it when looking. Did verify this is working as expected in the previous version 0.0.16, as well as the issue of image location being wrong.
In the output_images function, if multiple images exist on a single page in the PDF, some images are skipped entirely due to a logic issue.
Cause:
The issue occurs because the code deletes a value at the index from the img_rects list during forward iteration. This deletion shrinks the list, causing the iteration to skip over subsequent elements that haven't yet been processed.
Example:
For example, if img_rects initially contains:
parms.img_rects = [image1, image2, image3]
When image1 is processed and deleted, the list becomes:
parms.img_rects = [image2, image3]
The next iteration starts at index 1, skipping image2 entirely.
Proposed Fix:
Iterate Backwards - Modify the loop to iterate backward over the list, which ensures that deleting an element doesn’t affect the indices of unprocessed elements:
Seemed to solve the issue for me, however images were then in backwards order so I had to reverse the list.
The text was updated successfully, but these errors were encountered: