Word Document OpenXML - Resize multiple images to uniform size and maintains the ratio
<p>I am using OpenXML to insert an image into word document.</p>

<p>How to resize multiple images to uniform size and maintains the ratio?</p>

<p>Code is</p>

<pre><code>ImagePart imagePartTemp = mainDocumentPart.AddImagePart(ImagePartType.Jpeg);

imagePart2ID = mainDocumentPart.GetIdOfPart(imagePartTemp);

GenerateImagePart(imagePartTemp, sArticleImageTemp, ref imageWidthEMU2, ref imageHeightEMU2);

    newWidth = 6534150 * imageWidthEMU2 / imageHeightEMU2;
            newheight = 5876925 * imageHeightEMU2 / imageWidthEMU2;
            if (imageHeightEMU2 &gt; 6503510)
            {
                imageWidthEMU2 = newWidth;
                imageHeightEMU2 = newheight;
            }
            if (imageWidthEMU2 &gt; 6503510)
            {
                imageWidthEMU2 = newWidth;
                imageHeightEMU2 = newheight;
            }
            if (imageWidthEMU2 &gt; 5876925)
            {
                imageWidthEMU2 = 5876925;
            }
            if (imageHeightEMU2 &gt; 6534150)
            {
                imageHeightEMU2 = 6534150;
            }
</code></pre>
