Can I save a huge image GDS as PNG in python script

edited November 2023 in Python scripting

I try to convert gds file with size (152400 x 152400) pixel as PNG but time out with process error:

Process finished with exit code -1073741819 (0xC0000005)

Here is my code:

from klayout import db
from klayout import lay

input_file = "data/gps_data.gds"
layout = db.Layout()
layout_view = lay.LayoutView()
layout_view.set_config("background-color", "#FFFFFF")
layout_view.set_config("grid-visible", "false")
layout_view.show_layout(layout, False)
top_cell = layout.top_cell()
layout_view.active_cellview().cell = top_cell
for lyp in layout_view.each_layer():
    if lyp.layer_index() == 1:
        lyp.fill_color = 4294967295  
        lyp.frame_color = 4294967295  
        lyp.dither_pattern = 0
        lyp.transparent = True
    if lyp.layer_index() == 0:
        lyp.fill_color = 4279966491  
        lyp.frame_color = 4279966491  
        lyp.dither_pattern = 0
        lyp.transparent = True
box = top_cell.bbox()
print(box.width()//100, box.height()//100)
layout_view.save_image_with_options("test.png", box.width()//100, box.height()//100)

How much pixel size image can I output file as PNG image ?


  • That depends on the capabilities of the PNG library, but in my experience, the limit is around 50k x 50k pixels.

    It's somewhat better with monochrome images.


Sign In or Register to comment.