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...
Martin

Comments

  • 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 = pya.CellView.active().layout()
    
    # 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.

    Matthias

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

    Martin

  • 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,
    Martin

  • Hi mpee,
    I programmed this just yesterday

        a1=vi.get_config('grid-style1');
        a2=vi.get_config('grid-style2');
        a3=vi.get_config('grid-ruler-color')
        vi.set_config('grid-ruler-color','#50ff50');
        vi.set_config('grid-style1','invisible');
        vi.set_config('grid-style2','invisible')
        qi=vi.get_screenshot; b=vi.box
        b1=b.width/qi.width; b2=b.height/qi.height
        qi.setText(' ','Kommentarfeld')
        b=qi.save(fil,'JPG',96)
        vi.set_config('grid-style1',a1);vi.set_config('grid-style2',a2);vi.set_config('grid-ruler-color',a3)
        qi._destroy
    

    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
    Frank

  • Hi Frank,

    Your solution works perfectly fine on our side!

    Thank you very much,
    Martin

  • edited May 8

    @Frank Very good. That's basically the way I had proposed too.

    A warning from my side: people who ask for pure images usually want to use the images for some purpose - even mask making. Don't use these images for production purposes! They are made for visualization. The save_image_with_options function is not a quality rasterizer.

    Matthias

  • @Matthias: No we will not use this for mask making. It is used to identify layouts with visual based algorithms...

    Thanks anyway!
    Martin
Sign In or Register to comment.