From 9458a005de6ff4b8e9ac758e3867845f8c773abd Mon Sep 17 00:00:00 2001
From: mrded <mrded@556088.no-reply.drupal.org>
Date: Thu, 28 Aug 2014 17:07:24 +0100
Subject: [PATCH] File validate image resolution inaccurate in some situations

---
 core/modules/file/file.module | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index e17ab46..997a5fc 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -454,7 +454,16 @@ function file_validate_image_resolution(FileInterface $file, $maximum_dimensions
   // Check first that the file is an image.
   $image_factory = \Drupal::service('image.factory');
   $image = $image_factory->get($file->getFileUri());
+
   if ($image->isValid()) {
+    if ($maximum_dimensions && ($maximum_dimensions == $minimum_dimensions)) {
+      // Check that dimensions is exactly that given.
+      list($width, $height) = explode('x', $maximum_dimensions);
+      if ($image->getWidth() != $width || $image->getHeight() != $height) {
+        return array(t('The image must be exactly %dimensions pixels.', array('%dimensions' => $maximum_dimensions)));
+      }
+    }
+
     if ($maximum_dimensions) {
       // Check that it is smaller than the given dimensions.
       list($width, $height) = explode('x', $maximum_dimensions);
-- 
1.8.5.2 (Apple Git-48)

