GDS to image

Hi All,
We are using following cmd to generate large images from GDS files...

lv.save_image_with_options('XXX.jpg' , topcell.bbox().width()/1000, topcell.bbox().height()/1000, 0, 0, 0, pya.Box(), True)

But the problem we see is, that KLayout doesn't crop the image at the exact location where the layer information starts. It adds a large amount of additional area to the image (like a blank frame).

Is there any way to really snapshot the pure layers without this frame?

Furthermore, I would like to know if there is a chance to get rid of the scaler on the lower left part of the image...

Thank you very much...


  • Just specify the box you want to draw instead of leaving the decision to the function.

    Here is some code:

    lv = pya.LayoutView.current()
    ly =
    # top cell bounding box in micrometer units
    bbox = ly.top_cell().dbbox()
    # compute an image size having the same aspect ratio than 
    # the bounding box
    w = 640
    h = int(0.5 + w * bbox.height() / bbox.width())
    lv.save_image_with_options('/home/matthias/Pictures/discussion_1799.png', w, h, 0, 0, 0, bbox, True)

    Which for this layout:

    gives me this image:

    Which looks pretty much aligned if you allow for the upper and right side to vanish by being clipped.


  • Cool, thank you Matthias...
    That's exactly what we were looking for!


  • Hi Matthias,

    one more question...
    Is there any chance to get rid of the scale (Maßstab) and the gridlines at the image created by "lv.save_image_with_options"?

    Basically we are looking for a pure layout image capture without any additional information... Maybe if Klayout itself is not
    capable, would you now any python package that could do this job, which we may invoke into our klayout script?

    Thank you,

  • Hi mpee,
    I programmed this just yesterday

        b1=b.width/qi.width; b2=b.height/qi.height
        qi.setText(' ','Kommentarfeld'),'JPG',96)

    If you only want to disable grid and ruler you can do set_config('grid-visible','false'), but I have not tested.
    For more options see file klayoutrc

    Best regards

  • Hi Frank,

    Your solution works perfectly fine on our side!

    Thank you very much,

Sign In or Register to comment.