Problems with cv2? Alternative for resizing saved images on the fly?

  • Since DB's saveImage() doesn't allow me to resize images as I generate them (and is that right?), I was hoping to use the openCV-python library. But even after installing with pip3.7 and no --user flag I can't get DB to import cv2. Has anyone else run into this problem or gotten openCV to work in DB? Or does anyone have another suggestion for adjusting the size of saved images?

  • hello @MauriceMeilleur,

    you can set a different resolution when saving images in DrawBot. this can produce a different size in pixels than the document size (in points):

    size(100, 100)
    rect(10, 10, 80, 80)
    imgPath = '~/Desktop/malevich.png'
    saveImage(imgPath, imageResolution=144) # 200% = 72dpi * 2
    # (200, 200)

    you can also try using PIL/Pillow.


  • That's a nice workaround, thanks! I didn't consider the resolution parameter since I was thinking in terms of the absolute size of the image in pixels only. Maybe I'll put in a feature request, since pixel dimensions feels like a more intuitive way to characterize output.

Log in to reply