Detect a corrupt image file
<p>Hi All you clever guys,</p>

<p>Im faceing a bit of a challenge here.
Im supposed to create several different PDF's containing multiple (not similar) images.</p>

<p>Unfortunately some of the images are corrupt/defect. This causes the creation of the partikular PDF to fail/dump.</p>

<blockquote>
  <p>Is there a way I can test the image prior to creation of the PDF?</p>
</blockquote>

<p>Please be gentle with me. Im not an expert.</p>

<p>I found out that System.Drawings.Image can test some formats. Better than nothing I guess (it will reduce the subset significantly).</p>

<p>But when using iTextSharp.text.Image for the creation of the PDF's. Then I dont know how to use <code>the System.Drawings.Image</code> because when I try <code>Image newImage = Image.FromFile("SampImag.jpg");</code> then it (Image) refers to the <code>iTextSharp.text.Image</code> class.</p>

<p>System.Drawings.Image is abstract, so I've tried to create a subclass.</p>

<pre><code>public class ImageTest : System.Drawing.Image
    {

    }
</code></pre>

<p>Now I get the error message:<code>"Error 1   The type 'System.Drawing.Image' has no constructors defined"</code>
Trying to investigate which constructors I can use gives me this attempt.</p>

<pre><code>public class ImageTest : System.Drawing.Image
    {
      ImageTest(string filename);
      {
      }
    }
</code></pre>

<p>But this doesn't work.</p>

<p>Please inform me if there is information you need which is relevant to you for investigating this matter.</p>

<p>Thanks in advance.</p>