Binary Image Resizing and Properties

2 posts, 0 answers
  1. Allen
    Allen avatar
    21 posts
    Member since:
    Aug 2007

    Posted 09 Mar 2010 Link to this post

    I have a scenario like a few others listed in the forum where I have users than can upload any size image and I need to generate multiple sizes from the image.  I have seen examples of other posts on how to capture the image and that is working just fine.  However, I am having some trouble with the resizing.  Because of some of the manipulation that I need to do to the image regarding quality and because I do not know the file format (after the fact), I am wondering if there is a way to read some of the properties about the original file.  Specifically, because I have to deal with encoding, I need to get the image's original file format in order to alter the image quality or resolution.  I can obviously read the extension during the file upload, but the image processing may not always happen at that time and I don't really want to have an extra database field if it isn't needed.  So, is there a reasonable way to parse out of the file format from the binary image's "datavalue" or byte array?
  2. Allen
    Allen avatar
    21 posts
    Member since:
    Aug 2007

    Posted 09 Mar 2010 Link to this post

    Ok.  Ignore the previous post. :(  The issue I was having is apparently a "feature-bug" in the .NET framework.  I was trying to use the RawFormat property of the altered bitmap to save it back to a binary format.  It appears that when you begin processing a bitmap, the RawFormat value becomes an "internal" GUID which does not match any of the format enumerations.  What works in this case is to save your RawFormat value to a variable before processing the image and then using that value when converting back to binary.  Sorry for the bogus post and the confusion.
Back to Top