Note that there are some explanatory texts on larger screens.

plurals
  1. POthumbnail generation error c#
    primarykey
    data
    text
    <p>i am trying to create thumbnails. my path to original folder is: suppose <strong>I:\my images**, and i want to generate it to **i:\new images</strong>. i got two problem, <strong>first</strong> problem is that if <strong>my images folder contains subfolder</strong> then in the new images it should also be in the <strong>sub folder not as a parent folder</strong> .</p> <ul> <li><p><strong>second i got an Error.**A generic error occurred in GDI+.</strong></p> <p><strong>3rd i get this error: Out of memory.**</strong> </p></li> </ul> <p>its a csharp console application</p> <pre><code>at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) at System.Drawing.Image.Save(String filename, ImageFormat format) at ConsoleApplication1.Program.CreateThumbnail(String[] b, Double wid, Double hght, Boolean Isprint) public void CreateThumbnail(string[] b, double wid, double hght, bool Isprint) { string[] path; path = new string [64]; path = b; string saveath = "i:\\check\\a test\\"; for (int i = 0; i &lt; b.Length; i++) { DirectoryInfo dir = new DirectoryInfo(path[i]); string dir1 = dir.ToString(); dir1 = dir1.Substring(dir1.LastIndexOf("\\")); FileInfo[] files1 = dir.GetFiles(); foreach (FileInfo f in files1) { string gh = f.ToString(); try { System.Drawing.Image myThumbnail150; System.Drawing.Image.GetThumbnailImageAbort myCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); System.Drawing.Image imagesize = System.Drawing.Image.FromFile(f.FullName); Bitmap bitmapNew = new Bitmap(imagesize); double maxWidth = wid; double maxHeight = hght; int w = imagesize.Width; int h = imagesize.Height; // Longest and shortest dimension int longestDimension = (w &gt; h) ? w : h; int shortestDimension = (w &lt; h) ? w : h; // propotionality float factor = ((float)longestDimension) / shortestDimension; // default width is greater than height double newWidth = maxWidth; double newHeight = maxWidth / factor; // if height greater than width recalculate if (w &lt; h) { newWidth = maxHeight / factor; newHeight = maxHeight; } myThumbnail150 = bitmapNew.GetThumbnailImage((int)newWidth, (int)newHeight, myCallback, IntPtr.Zero); string ext = Path.GetExtension(f.Name); if (!Directory.Exists(saveath + dir1)) { Directory.CreateDirectory(saveath + dir1); myThumbnail150.Save(saveath + dir1 + "\\" + f.Name.Replace(ext, ".Jpeg"), System.Drawing.Imaging.ImageFormat.Jpeg); } else if(Directory.Exists(saveath+dir1)) { myThumbnail150.Save(saveath + dir1+" \\"+ f.Name.Replace(ext, ".Jpeg"), System.Drawing.Imaging.ImageFormat.Jpeg); } } catch (Exception ex) { Console.WriteLine("something went wrong" + ex.ToString()); } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload