When uploading images to D8 programmatically the setting for Maximum image resolution will be ignored and images will not be scaled down. Some of the images i have to upload are even larger then 10MB.
I am currently using this code.
$file_type = explode('.', $image)[1];
$data = file_get_contents($image);
$path = 'public://images/';
if (file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
$file = file_save_data($data, $path . md5($image) . '.' . $file_type, FILE_EXISTS_REPLACE);
$node = Node::create(array(
'type' => 'image',
'title' => $image,
'field_image' => array(
'target_id' => $file->id(),
),
));
$node->save();
}
I've tried to work with ImageStyle::load('max_2600x2600')
, but that will only create a style in styles directory.
It would be possible to use a custom shell command but i would love to use the Drupal 8 way. How to make sure original images will get resized?