# Import Image with Python Script

Hi,

In FDTD, I’d like to import a 2D image from a jpg or png file and create a 3D structure by extruding the image in the z-direction exactly as described here. This example uses the image import wizard. However, I would like to do this with a python script. I see that there are functions such as stlimport which can import CAD files and importbinary which can import binary files. I can’t seem to find a function that import jpg or png files. I’d like to take advantage of an importimage function if it is available. Does something like this exist?

Thank you

Hi @holdman

Since there are a few steps required to make sure that the image is imported properly, image import should be done in GUI. One workaround would be to import the images using GUI and saving them as simulation file. Then you can open the simulation file instead of opening a default instance. This can be done by placing the name of the file in the brackets:

FDTD.load("filename")

If you have any concern please let me know. You can also create a new feature request in IX:
https://ix.lumerical.com/

Ok thank you. I actually ended up using a work around where I wrote a python script to create a .txt file that could be read in with importbinary. Unfortunately, importing manually is not an option since I will be making iterative changes to the image and rerunning the script. Thank you for the response, though!

1 Like