hook_page_attachments is not the correct hook. You want to implement hook_preprocess_HOOK, like the example below.
There are some caveats with this fix, especially if your site will be localized to other languages, see the comments within the code:
/**
* Implements hook_preprocess_HOOK().
* Implements hook_preprocess_status_messages().
*
* @param $variables
*/
function mymodule_preprocess_status_messages(&$variables) {
if (isset($variables['message_list']['status'])) {
$status_messages = $variables['message_list']['status'];
$dummy_message_parameter_1 = '_parameter_1_';
$dummy_message_parameters = [
'%dimensions' => $dummy_message_parameter_1,
'%new_width' => 0,
'%new_height' => 0,
];
// The message could change eventually, but it is unlikely.
// This logic *could brake* in a some language translations, if the %dimensions string is not the first parameter.
$file_resize_message = t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels. The new dimensions of the resized image are %new_widthx%new_height pixels.', $dummy_message_parameters);
// $file_resize_message_start is the part of the message that won't vary.
$file_resize_message_start =strtok((string)$file_resize_message, $dummy_message_parameter_1); ;
foreach ($status_messages as $delta => $message) {
if (strpos((string)$message, $file_resize_message_start) !== FALSE) {
// The next commented line still leaves a green area
// unset($variables['message_list']['status'][$delta]);
// Removing all messages, the side effect is that you could be
// missing on some relevant messages
unset($variables['message_list']['status']);
}
}
}
}
The message is set in the function file_validate_image_resolution
at core/modules/file/file.module:447 (as of version 8.6.0-dev)
There is a good explanation about the hook implementation at Stack Overflow