To process images in a web application today, specify the image size and height. Google has a piece of information. I think this method is quite good. You can use it for reference. If your younger brother writes something wrong, please give us some advice: the following code is written in winform and can be used for testing on the web.
Code // Create a thumbnail Function
// Sequence parameters: source image file stream, thumbnail storage address, template width, and template height
// Note: the thumbnail size is controlled in the template area.
Public static void MakeSmallImg (System. IO. Stream fromFileStream, string fileSaveUrl, System. Double templateWidth, System. Double templateHeight)
{
// Obtain the image object from the file and use the color management information embedded in the stream
System. Drawing. Image myImage = System. Drawing. Image. FromStream (fromFileStream, true );
// Width and height of the thumbnail
System. Double newWidth = myImage. Width, newHeight = myImage. Height;
// The horizontal chart that is larger than the Template
If (myImage. Width> myImage. Height | myImage. Width = myImage. Height)
{
If (myImage. Width> templateWidth)
{
// Scale the width by template and the height by scale
NewWidth = templateWidth;
NewHeight = myImage. Height * (newWidth/myImage. Width );
}
}
// Portrait of a template
Else
{
If (myImage. Height> templateHeight)
{
// High by template, width by proportional Scaling
NewHeight = templateHeight;
NewWidth = myImage. Width *&