Hello .NET Gurus!
I have been posting messages all over the .NET forums to no avail, so I
thought I'd give this newsgroup a shot as well.
I am trying to figure out how to detect if a user-uploaded JPG file is in
Progressive or Baseline format. I need to determine this because the display
mechanism I am using (namely, flash) is not capable of displaying
Progressive JPGS. I have succesfully managed to detect the mime-type of the
files, but they always show as image/pjpeg, even when it's not a progressive
jpg file.
The closest I have gotten is that I did discover the RenderProgressive and
RenderNonProgressive members of the EncoderParameters enumeration. However,
these appear to be "write-only", e.g. they can be applied to the Encoder
object as parameters for encoding an existing file... but they can't be used
as a means by which to determine the properties of an existing file.
Furthermore, in the .NET docs on MSDN, these two parameters are documented
as being "Not used in GDI+ 1.0"
Lastly, I want to mention that using PHP it seems to be possible to detect
progressive jpgs by reading the binary code and looking for certain markers
or patterns using the following script.... But this is way over my head as
far as how to convert this code to somthing in VB or C#. So, forgive me for
posting PHP on a microsoft forum ;P ... but this is the only solid lead I
have!
<php code>
$fp = @fopen( $filename, "rb" );
$imageData = fread( $fp, 100000 );
@fclose( $fp );
function checkImage($imageData) {
if ( strstr( $imageData, pack( "n", 0xFFC2 ) ) ) {
return false;
}
if ( strstr( $imageData, pack( "n", 0xFFC6 ) ) ) {
return false;
}
if ( strstr( $imageData, pack( "n", 0xFFCA ) ) ) {
return false;
}
return true;
}
</php code>