Skip to content

Instantly share code, notes, and snippets.

@dnorment
dnorment / convert_eps_png.py
Created January 13, 2022 20:38
Convert .eps files to .png format
import subprocess
import os
def main():
# Iterate through all input files
filenames = [file for file in os.listdir(
os.getcwd()) if file.endswith('.eps')]
# Convert all .eps to .png
@dnorment
dnorment / render_and_cut_whitespace.py
Created January 4, 2021 19:41
Render and crop PDF
import cv2
import fitz
import numpy as np
import os
from fitz.fitz import Matrix
CROP_MARGIN = 10 # number of pixels to allow as margin in cropped image, 0 is too tight in many cases
IMG_SCALE = 5 # scale factor when turning PDF page into a raster map