<p>The error appears to be coming from the Imager plugin:</p>

<p><a href="https://github.com/aelvan/Imager-Craft/blob/master/imager/services/ImagerService.php#L1025" rel="nofollow noreferrer">https://github.com/aelvan/Imager-Craft/blob/master/imager/services/ImagerService.php#L1025</a></p>

<p>Make sure you're using the latest version, and then potentially post an issue here:</p>

<p><a href="https://github.com/aelvan/Imager-Craft/issues" rel="nofollow noreferrer">https://github.com/aelvan/Imager-Craft/issues</a></p>

CC BY-SA 3.0
2017-11-20T19:39:16.483Z
2017-11-20T19:39:16.483Z
andrew.welch
<p>It seems that an issue that was solved in craftcms 2.6.2991 is reintroduced afterwards.  I have just updated a site to version 2.6.2997 and the exactly the same error that was there prior to version 2.6.2991 is reappearing again on php 7.x environments</p>

<pre><code>"A non-numeric value encountered" /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/services/ImagerService.php(1025)

1013      * @param $transform
1014      * @return \Imagine\Image\Point
1015      */
1016     private function _getCropPoint($resizeSize, $cropSize, $transform)
1017     {
1018         // get default crop position from the settings
1019         $position = $this-&gt;getSetting('position', $transform);
1020 
1021         // get the offsets, left and top, now as an int, representing the % offset
1022         list($leftOffset, $topOffset) = explode(' ', $position);
1023         
1024         // get position that crop should center around
1025         $leftPos = floor($resizeSize-&gt;getWidth() * ($leftOffset / 100)) - floor($cropSize-&gt;getWidth()/2);
1026         $topPos = floor($resizeSize-&gt;getHeight() * ($topOffset / 100)) - floor($cropSize-&gt;getHeight()/2);
1027         
1028         // make sure the point is within the boundaries and return the point
1029         return new \Imagine\Image\Point(
1030             min(max($leftPos, 0), ($resizeSize-&gt;getWidth() - $cropSize-&gt;getWidth())), 
1031             min(max($topPos, 0), ($resizeSize-&gt;getHeight() - $cropSize-&gt;getHeight()))
1032         );
1033     }
1034 
1035 
1036     /**
1037      * Returns the filter method for resize operations
Stack Trace
- 0 
–  /var/www/vhosts/xxx/httpdocs/etc/app/etc/web/WebApp.php(693): CApplication-&gt;handleError(2, "A non-numeric value encountered", "/var/www/vhosts//httpdocs/etc/plugins/imager/s...", 1025)
688         if (version_compare(PHP_VERSION, '7.1', '&gt;=') &amp;&amp; strpos($message, 'Narrowing occurred during type inference. Please file a bug report') !== false)
689         {
690             return;
691         }
692 
693         parent::handleError($code, $message, $file, $line);
694     }
695 
696     // Private Methods
697     // =========================================================================
698 
- 1 
–  /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/services/ImagerService.php(1025): Craft\WebApp-&gt;handleError(2, "A non-numeric value encountered", "/var/www/vhosts/xxx/httpdocs/etc/plugins/imager/s...", 1025, ...)
1020 
1021         // get the offsets, left and top, now as an int, representing the % offset
1022         list($leftOffset, $topOffset) = explode(' ', $position);
1023         
1024         // get position that crop should center around
1025         $leftPos = floor($resizeSize-&gt;getWidth() * ($leftOffset / 100)) - floor($cropSize-&gt;getWidth()/2);
1026         $topPos = floor($resizeSize-&gt;getHeight() * ($topOffset / 100)) - floor($cropSize-&gt;getHeight()/2);
1027         
1028         // make sure the point is within the boundaries and return the point
1029         return new \Imagine\Image\Point(
1030             min(max($leftPos, 0), ($resizeSize-&gt;getWidth() - $cropSize-&gt;getWidth())), 
- 2 
–  /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/services/ImagerService.php(635): Craft\ImagerService-&gt;_getCropPoint(Imagine\Image\Box, Imagine\Image\Box, array("width" =&gt; 1200, "height" =&gt; 600, "mode" =&gt; "crop", "allowUpscale" =&gt; false, ...))
630             $layer-&gt;resize($resizeSize, $filterMethod);
631         }
632 
633         // Do the crop
634         if (!isset($transform['mode']) || mb_strtolower($transform['mode']) === 'crop' || mb_strtolower($transform['mode']) === 'croponly') {
635             $cropPoint = $this-&gt;_getCropPoint($resizeSize, $cropSize, $transform);
636             $layer-&gt;crop($cropPoint, $cropSize);
637         }
638 
639         // letterbox, add padding
640         if (isset($transform['mode']) &amp;&amp; mb_strtolower($transform['mode']) === 'letterbox') {
- 3 
–  /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/services/ImagerService.php(523): Craft\ImagerService-&gt;_transformLayer(Imagine\Imagick\Image, array("width" =&gt; 1200, "height" =&gt; 600, "mode" =&gt; "crop", "allowUpscale" =&gt; false, ...), "jpg", "jpg")
518                 }
519                 
520                 $this-&gt;imageInstance = $gif;
521 
522             } else {
523                 $this-&gt;_transformLayer($this-&gt;imageInstance, $transform, $sourceExtension, $targetExtension);
524             }
525             
526             // If Image Driver is imagick and removeMetadata is true, remove meta data
527             if ($this-&gt;imageDriver === 'imagick' &amp;&amp; $this-&gt;getSetting('removeMetadata', $transform)) {
528                 $this-&gt;imageInstance-&gt;strip();
- 6 
–  /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/services/ImagerService.php(341): Craft\ImagerService-&gt;_getTransformedImage(Craft\Imager_ImagePathsModel, array("width" =&gt; 1200, "height" =&gt; 600, "mode" =&gt; "crop", "allowUpscale" =&gt; false, ...))
336         $r = null;
337 
338         if (isset($transform[0])) {
339             $transformedImages = array();
340             foreach ($transform as $t) {
341                 $transformedImage = $this-&gt;_getTransformedImage($pathsModel, $transformDefaults != null ? array_merge($transformDefaults, $t) : $t);
342                 $transformedImages[] = $transformedImage;
343             }
344             $r = $transformedImages;
345         } else {
346             $transformedImage = $this-&gt;_getTransformedImage($pathsModel, $transformDefaults != null ? array_merge($transformDefaults, (array)$transform) : $transform);
- 5 
–  /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/variables/ImagerVariable.php(26): Craft\ImagerService-&gt;transformImage(Craft\AssetFileModel, array(array("width" =&gt; 1200, "ratio" =&gt; 2), array("width" =&gt; 1024, "ratio" =&gt; 2), array("width" =&gt; 768, "ratio" =&gt; 1.3333333333333, "jpegQuality" =&gt; 65)), array("format" =&gt; "jpg", "allowUpscale" =&gt; false, "mode" =&gt; "crop", "jpegQuality" =&gt; 80, ...), null)
21      * @param $configOverrides
22      * @return mixed
23      */
24     public function transformImage($file, $transform, $transformDefaults = null, $configOverrides = null)
25     {
26         $image = craft()-&gt;imager-&gt;transformImage($file, $transform, $transformDefaults, $configOverrides);
27         return $image;
28     }
29 
30     /**
31      * Takes an array of Imager_ImageModel (or anything else that supports getUrl() and getWidth())
...
...
</code></pre>

CC BY-SA 3.0
2017-11-20T14:59:39.340Z
Can you enable devMode and edit the question to show the full stack trace leading up to the error?
Brad Bell
CC BY-SA 3.0
2017-11-20T16:06:23.137Z
That is a notice/warning that was introduced in PHP 7.1 (see https://stackoverflow.com/a/42044413/1688568). There are countless places where it could potentially occur, so we’d need to see your stack trace to have an idea of what the culprit is this time. You can get that by enabling Dev Mode, as Braid said, or you might be able to find it by searching for the error in craft/storage/runtime/logs/.
Brandon Kelly
CC BY-SA 3.0
2017-11-20T17:39:51.400Z
I might have underdone it a bit.. I hope it is readable enough, if not let me know
Tim Bertens
<craft-pro><plugin-imager>
"A non-numeric value encountered" reintroduced after version 2.6.2991
# "A non-numeric value encountered" reintroduced after version 2.6.2991

(Asked by: username_0 on 2017-11-20)

It seems that an issue that was solved in craftcms 2.6.2991 is reintroduced afterwards.  I have just updated a site to version 2.6.2997 and the exactly the same error that was there prior to version 2.6.2991 is reappearing again on php 7.x environments
"A non-numeric value encountered" /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/services/ImagerService.php(1025)

1013      * @param $transform
1014      * @return \Imagine\Image\Point
1015      */
1016     private function _getCropPoint($resizeSize, $cropSize, $transform)
1017     {
1018         // get default crop position from the settings
1019         $position = $this->getSetting('position', $transform);
1020 
1021         // get the offsets, left and top, now as an int, representing the % offset
1022         list($leftOffset, $topOffset) = explode(' ', $position);
1023         
1024         // get position that crop should center around
1025         $leftPos = floor($resizeSize->getWidth() * ($leftOffset / 100)) - floor($cropSize->getWidth()/2);
1026         $topPos = floor($resizeSize->getHeight() * ($topOffset / 100)) - floor($cropSize->getHeight()/2);
1027         
1028         // make sure the point is within the boundaries and return the point
1029         return new \Imagine\Image\Point(
1030             min(max($leftPos, 0), ($resizeSize->getWidth() - $cropSize->getWidth())), 
1031             min(max($topPos, 0), ($resizeSize->getHeight() - $cropSize->getHeight()))
1032         );
1033     }
1034 
1035 
1036     /**
1037      * Returns the filter method for resize operations
Stack Trace
- 0 
–  /var/www/vhosts/xxx/httpdocs/etc/app/etc/web/WebApp.php(693): CApplication->handleError(2, "A non-numeric value encountered", "/var/www/vhosts//httpdocs/etc/plugins/imager/s...", 1025)
688         if (version_compare(PHP_VERSION, '7.1', '>=') && strpos($message, 'Narrowing occurred during type inference. Please file a bug report') !== false)
689         {
690             return;
691         }
692 
693         parent::handleError($code, $message, $file, $line);
694     }
695 
696     // Private Methods
697     // =========================================================================
698 
- 1 
–  /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/services/ImagerService.php(1025): Craft\WebApp->handleError(2, "A non-numeric value encountered", "/var/www/vhosts/xxx/httpdocs/etc/plugins/imager/s...", 1025, ...)
1020 
1021         // get the offsets, left and top, now as an int, representing the % offset
1022         list($leftOffset, $topOffset) = explode(' ', $position);
1023         
1024         // get position that crop should center around
1025         $leftPos = floor($resizeSize->getWidth() * ($leftOffset / 100)) - floor($cropSize->getWidth()/2);
1026         $topPos = floor($resizeSize->getHeight() * ($topOffset / 100)) - floor($cropSize->getHeight()/2);
1027         
1028         // make sure the point is within the boundaries and return the point
1029         return new \Imagine\Image\Point(
1030             min(max($leftPos, 0), ($resizeSize->getWidth() - $cropSize->getWidth())), 
- 2 
–  /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/services/ImagerService.php(635): Craft\ImagerService->_getCropPoint(Imagine\Image\Box, Imagine\Image\Box, array("width" => 1200, "height" => 600, "mode" => "crop", "allowUpscale" => false, ...))
630             $layer->resize($resizeSize, $filterMethod);
631         }
632 
633         // Do the crop
634         if (!isset($transform['mode']) || mb_strtolower($transform['mode']) === 'crop' || mb_strtolower($transform['mode']) === 'croponly') {
635             $cropPoint = $this->_getCropPoint($resizeSize, $cropSize, $transform);
636             $layer->crop($cropPoint, $cropSize);
637         }
638 
639         // letterbox, add padding
640         if (isset($transform['mode']) && mb_strtolower($transform['mode']) === 'letterbox') {
- 3 
–  /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/services/ImagerService.php(523): Craft\ImagerService->_transformLayer(Imagine\Imagick\Image, array("width" => 1200, "height" => 600, "mode" => "crop", "allowUpscale" => false, ...), "jpg", "jpg")
518                 }
519                 
520                 $this->imageInstance = $gif;
521 
522             } else {
523                 $this->_transformLayer($this->imageInstance, $transform, $sourceExtension, $targetExtension);
524             }
525             
526             // If Image Driver is imagick and removeMetadata is true, remove meta data
527             if ($this->imageDriver === 'imagick' && $this->getSetting('removeMetadata', $transform)) {
528                 $this->imageInstance->strip();
- 6 
–  /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/services/ImagerService.php(341): Craft\ImagerService->_getTransformedImage(Craft\Imager_ImagePathsModel, array("width" => 1200, "height" => 600, "mode" => "crop", "allowUpscale" => false, ...))
336         $r = null;
337 
338         if (isset($transform[0])) {
339             $transformedImages = array();
340             foreach ($transform as $t) {
341                 $transformedImage = $this->_getTransformedImage($pathsModel, $transformDefaults != null ? array_merge($transformDefaults, $t) : $t);
342                 $transformedImages[] = $transformedImage;
343             }
344             $r = $transformedImages;
345         } else {
346             $transformedImage = $this->_getTransformedImage($pathsModel, $transformDefaults != null ? array_merge($transformDefaults, (array)$transform) : $transform);
- 5 
–  /var/www/vhosts/xxx/httpdocs/etc/plugins/imager/variables/ImagerVariable.php(26): Craft\ImagerService->transformImage(Craft\AssetFileModel, array(array("width" => 1200, "ratio" => 2), array("width" => 1024, "ratio" => 2), array("width" => 768, "ratio" => 1.3333333333333, "jpegQuality" => 65)), array("format" => "jpg", "allowUpscale" => false, "mode" => "crop", "jpegQuality" => 80, ...), null)
21      * @param $configOverrides
22      * @return mixed
23      */
24     public function transformImage($file, $transform, $transformDefaults = null, $configOverrides = null)
25     {
26         $image = craft()->imager->transformImage($file, $transform, $transformDefaults, $configOverrides);
27         return $image;
28     }
29 
30     /**
31      * Takes an array of Imager_ImageModel (or anything else that supports getUrl() and getWidth())
...
...

**Tags:** craft-pro, plugin-imager
> **Comments:**
> **username_1**: Can you enable devMode and edit the question to show the full stack trace leading up to the error?  
> **username_2**: That is a notice/warning that was introduced in PHP 7.1 (see https://stackoverflow.com/a/42044413/1688568). There are countless places where it could potentially occur, so we’d need to see your stack trace to have an idea of what the culprit is this time. You can get that by enabling Dev Mode, as Braid said, or you might be able to find it by searching for the error in craft/storage/runtime/logs/.  
> **username_0**: I might have underdone it a bit.. I hope it is readable enough, if not let me know  

---

## 1 answers

### Answer by username_3 on 2017-11-20. Score: 1

The error appears to be coming from the Imager plugin:

<https://github.com/aelvan/Imager-Craft/blob/master/imager/services/ImagerService.php#L1025>

Make sure you're using the latest version, and then potentially post an issue here:

<https://github.com/aelvan/Imager-Craft/issues>


---

