Im having issue creating thumbnail image based on original image that is already stored on disk.
App throws: 'A generic error occurred in GDI+.'
Here is my code:
public static string UploadThumbnailImage(string existingImagePath)
{
var fileName = "thumb_" + Guid.NewGuid().ToString() + ".jpg";
var filePath = Path.Combine("Uploads/Images", fileName);
originalFilePath = Path.GetFullPath(existingImagePath);
using (var stream = File.Create(filePath))
{
// getting original image that I want create thumbnail image based on
var image = Image.FromFile(originalFilePath);
// created thumbnail image based on original image
var thumb = image.GetThumbnailImage(150, 150, () => false, IntPtr.Zero);
// saving thumbnail image - and this throws
// 'A generic error occurred in GDI+.'
thumb.Save(filePath);
}
string thumbnailImageUrl = string.Format("/{0}/{1}", "Uploads/Images", fileName);
return thumbnailImageUrl;
}