core-bundle/src/Resources/contao/library/Contao/Picture.php
public function getTemplateData()
	{
		$rootDir = System::getContainer()->getParameter('kernel.project_dir');
		$image = System::getContainer()->get('contao.image.image_factory')->create($rootDir . '/' . $this->image->getOriginalPath());

		$config = new PictureConfiguration();
		$config->setSize($this->getConfigurationItem($this->imageSize));

		$sizeItems = array();

		foreach ($this->imageSizeItems as $imageSizeItem)
		{
			$sizeItems[] = $this->getConfigurationItem($imageSizeItem);
		}

		$config->setSizeItems($sizeItems);

		$importantPart = $this->image->getImportantPart();

		$image->setImportantPart(
			new ImportantPart(
				new Point($importantPart['x'], $importantPart['y']),
				new Box($importantPart['width'], $importantPart['height'])
			)
		);

		$container = System::getContainer();
		$staticUrl = $container->get('contao.assets.files_context')->getStaticUrl();

		$picture = $container
			->get('contao.image.picture_generator')
			->generate(
				$image,
				$config,
				(new ResizeOptions())
					->setImagineOptions($container->getParameter('contao.image.imagine_options'))
					->setBypassCache($container->getParameter('contao.image.bypass_cache'))
			)
		;

		return array
		(
			'img' => $picture->getImg($rootDir, $staticUrl),
			'sources' => $picture->getSources($rootDir, $staticUrl),
		);
	}
public function getTemplateData()
	{
		$rootDir = System::getContainer()->getParameter('kernel.project_dir');
		$image = System::getContainer()->get('contao.image.image_factory')->create($rootDir . '/' . $this->image->getOriginalPath());

		$config = new PictureConfiguration();
		$config->setSize($this->getConfigurationItem($this->imageSize));

		$sizeItems = array();

		foreach ($this->imageSizeItems as $imageSizeItem)
		{
			$sizeItems[] = $this->getConfigurationItem($imageSizeItem);
		}

		$config->setSizeItems($sizeItems);

		$importantPart = $this->image->getImportantPart();

		$image->setImportantPart(
			new ImportantPart(
				new Point($importantPart['x'], $importantPart['y']),
				new Box($importantPart['width'], $importantPart['height'])
			)
		);

		$container = System::getContainer();
		$staticUrl = $container->get('contao.assets.files_context')->getStaticUrl();

		$picture = $container
			->get('contao.image.picture_generator')
			->generate(
				$image,
				$config,
				(new ResizeOptions())
					->setImagineOptions($container->getParameter('contao.image.imagine_options'))
					->setBypassCache($container->getParameter('contao.image.bypass_cache'))
			)
		;

		return array
		(
			'img' => $picture->getImg($rootDir, $staticUrl),
			'sources' => $picture->getSources($rootDir, $staticUrl),
		);
	}
Get the picture element definition array

@return array The picture element definition