I need a way to calculate the width and height values of an image when resized to 1024px
The largest value of the image, height or width will be resized to 1024px and I need to figure out the remaining width or height value.
An image (3200 x 2400px) converts to (1024 x 768px) when resized.
This needs to be dynamic as some images will be portrait and some landscape.
Can anyone suggest how I'd work a solution into the following:
<msxsl:script language="C#" implements-prefix="emint">
<![CDATA[public string GetExtension(string fileName)
{
string[] terms = fileName.Split('.');
if (terms.Length <= 0)
{
return string.Empty;
}
return terms[terms.Length -1];
}
public string GetFileName(string fileName)
{
string[] terms = fileName.Split('/');
if (terms.Length <= 0)
{
return string.Empty;
}
return terms[terms.Length -1];
}
public string GetFileSize(Decimal mbs)
{
Decimal result = Decimal.Round(mbs, 2);
if (result == 0)
{
result = mbs * 1024;
return Decimal.Round(result, 2).ToString() + " KB";
}
return result.ToString() + " MB";
}
public string GetCentimeters(Decimal pix)
{
Decimal formula = (decimal)0.026458333;
Decimal result = pix * formula;
return Decimal.Round(result,0).ToString();
}]]>
</msxsl:script>