1105

· 👁 19 views

#commons

The server did not respond within the expected time

If you cannot upload your big #pdf - you can extract all images from it, with original quality:

import fitz  # PyMuPDF

doc = fitz.open('your_file.pdf')
for page_index in range(len(doc)):
    for img_index, img in enumerate(doc.get_page_images(page_index)):
        xref = img[0]
        base_image = doc.extract_image(xref)
        image_bytes = base_image['image']
        image_ext = base_image['ext']  # Preserve original format (e.g., 'jpeg', 'png', 'jp2')
        with open(f'page{page_index+1}_{img_index+1}.{image_ext}', 'wb') as f:
            f.write(image_bytes)

and upload through my #pywikibot wrapper https://gitlab.com/vitaly-zdanevich/pwb_wrapper_for_simpler_uploading_to_commons