diff --git a/inc/template.php b/inc/template.php
index a5135d3e6d3a2f6e5ca08b9ae40db295c71e5e63..1e0af91c8ea83008448fa891dc534a7bcfad72bc 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1224,8 +1224,8 @@ function tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null) {
     /** @var Input $INPUT */
     global $INPUT;
     global $REV;
-    $w = tpl_img_getTag('File.Width');
-    $h = tpl_img_getTag('File.Height');
+    $w = (int) tpl_img_getTag('File.Width');
+    $h = (int) tpl_img_getTag('File.Height');
 
     //resize to given max values
     $ratio = 1;