porting newimagedlg.py