Browse Source

Merge pull request #493 from AntonyCorbett/var_scope_change_02

reduce variable scope
Marcin Ziąbek 2 years ago
parent
commit
c00ac5e9c7
1 changed files with 4 additions and 3 deletions
  1. 4 3
      Source/QuestPDF/Fluent/ImageExtensions.cs

+ 4 - 3
Source/QuestPDF/Fluent/ImageExtensions.cs

@@ -32,16 +32,17 @@ namespace QuestPDF.Fluent
             if (image == null)
                 throw new DocumentComposeException("Cannot load or decode provided image.");
             
-            var aspectRatio = image.Width / (float)image.Height;
-            
             var imageElement = new Image
             {
                 InternalImage = image
             };
 
             if (scaling != ImageScaling.Resize)
+            {
+                var aspectRatio = image.Width / (float)image.Height;
                 parent = parent.AspectRatio(aspectRatio, Map(scaling));
-            
+            }
+
             parent.Element(imageElement);
 
             static AspectRatioOption Map(ImageScaling scaling)