Aim: To resize the images based on the resolution
Problem : If we do not resize, the alignment and image structuring will be gone
Need of the following code : I don’t want to resize a small images to 100% width.
System.Drawing.Image img = System.Drawing.Image.FromFile(imgTest.Src);
if (img.HorizontalResolution > 1000)
{
imgTest.Attributes.Add("width", "100%");
}
Am I in the right way ? Or is there any other alternatives to do the same ? Let me know, can I replace the C# code using any CSS ?
Can you be more specific?
Basically are you storing the image somewhere in the new size?
Or do you simply wish to show the image inside a DIV or td which needs to be of a certain width / height?
And if I understand you right, you are just looking to resize larger images, so anything below a threshold should not get resized, right?
If it is simple for display, you can ditch all of this and just use CSS
This will make any image that exceeds either of these constraints smaller but with fixed aspect ratio.
This link explains the basics of these CSS properties http://www.w3schools.com/cssref/pr_dim_max-height.asp
Let me know if this was helpful! Cheers!