public function __construct(File $file)
{
@trigger_error('Using new Contao\\Image() has been deprecated and will no longer work in Contao 5.0. Use the contao.image.image_factory service instead.', E_USER_DEPRECATED);
// Check whether the file exists
if (!$file->exists()) {
// Handle public bundle resources
if (file_exists(TL_ROOT . '/web/' . $file->path)) {
$file = new \File('web/' . $file->path);
} else {
throw new \InvalidArgumentException('Image "' . $file->path . '" could not be found');
}
}
$this->fileObj = $file;
$arrAllowedTypes = \StringUtil::trimsplit(',', strtolower(\Config::get('validImageTypes')));
// Check the file type
if (!in_array($this->fileObj->extension, $arrAllowedTypes)) {
throw new \InvalidArgumentException('Image type "' . $this->fileObj->extension . '" was not allowed to be processed');
}
}