protected void Page_Load(object sender, EventArgs e)
    {
        string imgPath;

        if (Request.QueryString["ImageId"] != null)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["ImageId"].ToString()))
            {
                imgPath = Request.QueryString["ImageId"].ToString();
                if (!string.IsNullOrEmpty(imgPath))
                {
                    bool grande;
                    try
                    {
                        if (Request.QueryString["img"].ToString() != null)
                        {
                            grande = true;
                        }
                        else
                        {
                            grande = false;
                        }
                    }
                    catch
                    {
                        grande = false;
                    }
                    if (grande)
                    {
                        string aux = "";
                        aux = imgPath.Substring(0, imgPath.IndexOf("_thumb"));
                        aux = aux + imgPath.Substring(imgPath.IndexOf("_thumb") + 6, 4);
                        byte[] imgByte = GetImageByteArr(new Bitmap(aux));
                        Context.Response.ContentType = "image/gif";
                        Context.Response.BinaryWrite(imgByte);
                    }
                    else
                    {
                        byte[]       imgByte      = GetImageByteArr(new Bitmap(imgPath));
                        MemoryStream memoryStream = new MemoryStream();
                        memoryStream.Write(imgByte, 0, imgByte.Length);
                        System.Drawing.Image imagen = System.Drawing.Image.FromStream(memoryStream);
                        Response.ContentType = "image/Jpeg";
                        ImageResize ir = new ImageResize();
                        ir.File   = imagen;
                        ir.Height = imagen.Size.Height;
                        ir.Width  = imagen.Size.Width;
                        ir.GetThumbnail().Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string imgPath;
        if (Request.QueryString["ImageId"] != null)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["ImageId"].ToString()))
            {
                imgPath = Request.QueryString["ImageId"].ToString();
                if (!string.IsNullOrEmpty(imgPath))
                {

                    bool grande;
                    try
                    {
                        if (Request.QueryString["img"].ToString() != null)
                            grande = true;
                        else
                            grande = false;
                    }
                    catch
                    {
                        grande = false;
                    }
                    if (grande)
                    {
                        string aux = "";
                        aux = imgPath.Substring(0, imgPath.IndexOf("_thumb"));
                        aux = aux + imgPath.Substring(imgPath.IndexOf("_thumb") + 6, 4);
                        byte[] imgByte = GetImageByteArr(new Bitmap(aux));
                        Context.Response.ContentType = "image/gif";
                        Context.Response.BinaryWrite(imgByte);
                    }
                    else
                    {
                        byte[] imgByte = GetImageByteArr(new Bitmap(imgPath));
                        MemoryStream memoryStream = new MemoryStream();
                        memoryStream.Write(imgByte, 0, imgByte.Length);
                        System.Drawing.Image imagen = System.Drawing.Image.FromStream(memoryStream);
                        Response.ContentType = "image/Jpeg";
                        ImageResize ir = new ImageResize();
                        ir.File = imagen;
                        ir.Height = imagen.Size.Height;
                        ir.Width = imagen.Size.Width;
                        ir.GetThumbnail().Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Retrieves a binary array from the SQL Server database by the use of the
    /// <see dbAccess>dbAccess</see>class. Once this binary
    /// array is retrtieved from the database, it is written to a memory stream
    /// which is then written to the standard Html Response stream, this binary data represents
    /// an image from the database, which has been scaled using the fields within this class
    /// </summary>
    private void Page_Load(object sender, System.EventArgs e)
    {
        byte[]       imageData = null;
        MemoryStream ms        = null;

        System.Drawing.Image fullsizeImage = null;
        String imageID = null;

        if (!Page.IsPostBack)
        {
            try
            {
                // get the ID of the image to retrieve from the database
                imageID   = Request.QueryString[IMAGE_ID];
                imageData = dbAccess.GetImageByID(int.Parse(imageID));

                //create an image from the byte array
                ms            = new MemoryStream(imageData);
                fullsizeImage = System.Drawing.Image.FromStream(ms);

                Response.ContentType = "image/Jpeg";
                ImageResize ir = new ImageResize();

                //  Load your image and perform any resizing here
                ir.File = fullsizeImage;
                if (USE_SIZE_FOR_HEIGHT)
                {
                    ir.Height = THUMBNAIL_SIZE;
                }
                else
                {
                    ir.Width = THUMBNAIL_SIZE;
                }
                //get the thumbnail
                ir.GetThumbnail().Save(Response.OutputStream,
                                       System.Drawing.Imaging.ImageFormat.Jpeg);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                ms.Close();
            }
        }
    }