mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
fixed #596: Fix "Save thumbnail image to file" issue
This commit is contained in:
parent
a8ae843867
commit
3a4a8798c2
2 changed files with 17 additions and 11 deletions
|
@ -45,6 +45,12 @@ public Resize()
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Resize(int width, int height)
|
||||||
|
{
|
||||||
|
Width = width;
|
||||||
|
Height = height;
|
||||||
|
}
|
||||||
|
|
||||||
public override Image Apply(Image img)
|
public override Image Apply(Image img)
|
||||||
{
|
{
|
||||||
if (Width <= 0 && Height <= 0) return img;
|
if (Width <= 0 && Height <= 0) return img;
|
||||||
|
|
|
@ -267,19 +267,11 @@ public static string CreateThumbnail(Image img, string folder, string filename,
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
thumbImage = (Image)img.Clone();
|
thumbImage = (Image)img.Clone();
|
||||||
thumbImage = new Resize
|
thumbImage = new Resize(taskSettings.ImageSettings.ThumbnailWidth, taskSettings.ImageSettings.ThumbnailHeight).Apply(thumbImage);
|
||||||
{
|
|
||||||
Width = taskSettings.ImageSettings.ThumbnailWidth,
|
|
||||||
Height = taskSettings.ImageSettings.ThumbnailHeight
|
|
||||||
}.Apply(thumbImage);
|
|
||||||
thumbImage = ImageHelpers.FillBackground(thumbImage, Color.White);
|
thumbImage = ImageHelpers.FillBackground(thumbImage, Color.White);
|
||||||
thumbImage.SaveJPG(thumbnailFilePath, 90);
|
thumbImage.SaveJPG(thumbnailFilePath, 90);
|
||||||
return thumbnailFilePath;
|
return thumbnailFilePath;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
DebugHelper.WriteException(e);
|
|
||||||
}
|
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (thumbImage != null)
|
if (thumbImage != null)
|
||||||
|
@ -308,8 +300,16 @@ public static MemoryStream SaveImageAsStream(Image img, EImageFormat imageFormat
|
||||||
img.Save(stream, ImageFormat.Png);
|
img.Save(stream, ImageFormat.Png);
|
||||||
break;
|
break;
|
||||||
case EImageFormat.JPEG:
|
case EImageFormat.JPEG:
|
||||||
|
try
|
||||||
|
{
|
||||||
|
img = (Image)img.Clone();
|
||||||
img = ImageHelpers.FillBackground(img, Color.White);
|
img = ImageHelpers.FillBackground(img, Color.White);
|
||||||
img.SaveJPG(stream, jpegQuality);
|
img.SaveJPG(stream, jpegQuality);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (img != null) img.Dispose();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case EImageFormat.GIF:
|
case EImageFormat.GIF:
|
||||||
img.SaveGIF(stream, gifQuality);
|
img.SaveGIF(stream, gifQuality);
|
||||||
|
|
Loading…
Reference in a new issue