building type assertion in imagehandlerfunc