Как изменить размер изображения и сохранить в папке?

Я попробовал это:

string str = System.IO.Path.GetFileName(txtImage.Text);
string pth = System.IO.Directory.GetCurrentDirectory() + "\\Subject";
string fullpath = pth + "\\" + str;

Image NewImage = clsImage.ResizeImage(fullpath, 130, 140, true);
NewImage.Save(fullpath, ImageFormat.Jpeg); 
public static Image ResizeImage(string file, int width, int height, bool onlyResizeIfWider)
{
    if (File.Exists(file) == false)
        return null;
    try
    {
        using (Image image = Image.FromFile(file))
        {
            // Prevent using images internal thumbnail
            image.RotateFlip(RotateFlipType.Rotate180FlipNone);
            image.RotateFlip(RotateFlipType.Rotate180FlipNone);
            if (onlyResizeIfWider == true)
            {
                if (image.Width <= width)
                {
                    width = image.Width;
                }
            }
            int newHeight = image.Height * width / image.Width;
            if (newHeight > height)
            {
                // Resize with height instead
                width = image.Width * height / image.Height;
                newHeight = height;
            }
            Image NewImage = image.GetThumbnailImage(width, newHeight, null, IntPtr.Zero);
            return NewImage;
        }
    }
    catch (Exception )
    {
        return null;
    }
}

Запустив приведенный выше код, я получаю изображение размером 4-5 КБ с очень низким качеством изображения. Исходный файл изображения имеет размер не более 1,5 МБ. Как я могу улучшить качество изображения результатов?

Ответы на вопрос(1)

Ваш ответ на вопрос