GDS2PNG -- using KLayout

Maple

Problem

In some special application, the pattern load by machine must be .bmp type picture file.

Solution

KLayout is a layout viewer and editor wihich is open source.

The interface of KLayout
The interface of KLayout

First, adjusting stipple and other layers properties. You must tick checkbox Color and choose any color you want.
Then, in menu bar, opening Macros->Macros Development, the script interface will showed. Here we choose python, use code as following:
The script interface of KLayout
The script interface of KLayout

gds2png.pyGDS2PNG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
resolution = 1 #um/pixel
out_path = './preview.bmp'

import pya
lv = pya.LayoutView.current()
ly = pya.CellView.active().layout()

# top cell bounding box in micrometer units

bbox = ly.top_cell().dbbox()

# Set an image size having the same aspect ratio as
# the bounding box, *1000 means magnifing 1000 times.
# Because unit of gds is um in default, so now resolution is 1 nm/pixels.

w = round(bbox.width()/resolution)
h = round(bbox.height()/resolution)

lv.save_image_with_options(out_path, w, h, 0, 0, 0, bbox, True)

print('done')

Run this script, and you will get a one-bit bmp file.

  • Title: GDS2PNG -- using KLayout
  • Author: Maple
  • Created at : 2023-10-27 11:21:13
  • Updated at : 2025-03-20 16:10:15
  • Link: https://www.maple367.eu.org/Tools/gds2png-using-klayout/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
GDS2PNG -- using KLayout