回答:
以下のコードを使用して画像のURLを取得します view
<img src="<?php echo $this->getViewFileUrl('Vendor_Module::images/image.png'); ?>" />更新:
<?php echo $block->getViewFileUrl('images/demo.jpg'); ?>ヘルパーまたはコントローラーで画像パスを取得するには、使用する必要があります
use Magento\Framework\View\Asset\Repository;
use Magento\Framework\App\RequestInterface; // for $this->requestファイル内。
リポジトリを追加してオブジェクトassetRepo&を作成したらrequest、関数でイメージパスを呼び出し、
$params = array('_secure' => $this->request->isSecure());
$this->assetRepo->getUrlWithParams('Nitesh_Module::images/image.png', $params);vendor\magento\module-payment\Model\CcConfig.php::getViewFileUrl($fileId, array $params = [])機能を参照
編集
セットアップスクリプト、API呼び出し、Cronjobsの正しい画像パスを取得するには、以下のようなエミュレーションを追加して正しい画像パスを取得する必要があります。
public function __construct(
    \Magento\Framework\View\Asset\Repository $assetRepo,
    \Magento\Framework\App\RequestInterface $request,
    \Magento\Store\Model\App\Emulation $appEmulation
)
{
    $this->assetRepo = $assetRepo;
    $this->request = $request;
    $this->appEmulation = $appEmulation;
}
public FunctionName($param){
    $this->appEmulation->startEnvironmentEmulation($storeId, \Magento\Framework\App\Area::AREA_FRONTEND, true);
    $params = array('_secure' => $this->request->isSecure());
    $this->assetRepo->getUrlWithParams('Nitesh_Module::images/image.png', $params);
    $this->appEmulation->stopEnvironmentEmulation();
}