public void ProcessRequest(HttpContext context)
        {
            var w       = Utils.RequestQueryStringParam(context, "w");
            var h       = Utils.RequestQueryStringParam(context, "h");
            var src     = Utils.RequestQueryStringParam(context, "src");
            var imgtype = Utils.RequestQueryStringParam(context, "imgtype");

            if (h == "")
            {
                h = "0";
            }
            if (w == "")
            {
                w = "0";
            }

            if (Utils.IsNumeric(w) && Utils.IsNumeric(h))
            {
                src = HttpContext.Current.Server.MapPath(src);

                var strCacheKey = context.Request.Url.Host.ToLower() + "*" + src + "*" + Utils.GetCurrentCulture() + "*img:" + w + "*" + h + "*";
                var newImage    = (Bitmap)Utils.GetCache(strCacheKey);

                if (newImage == null)
                {
                    newImage = ImgUtils.CreateThumbnail(src, Convert.ToInt32(w), Convert.ToInt32(h));
                    Utils.SetCache(strCacheKey, newImage);
                }

                if ((newImage != null))
                {
                    ImageCodecInfo useEncoder;

                    // due to issues on some servers not outputing the png format correctly from the thumbnailer.
                    // this thumbnailer will always output jpg, unless specifically told to do a png format.
                    useEncoder = ImgUtils.GetEncoder(ImageFormat.Jpeg);
                    if (imgtype.ToLower() == "png")
                    {
                        useEncoder = ImgUtils.GetEncoder(ImageFormat.Png);
                    }

                    var encoderParameters = new EncoderParameters(1);
                    encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 85L);

                    try
                    {
                        newImage.Save(context.Response.OutputStream, useEncoder, encoderParameters);
                    }
                    catch (Exception exc)
                    {
                        var outArray = Utils.StrToByteArray(exc.ToString());
                        context.Response.OutputStream.Write(outArray, 0, outArray.Count());
                    }
                }
            }
        }
        /// <summary>
        /// Thumbnail image
        /// </summary>
        /// <param name="info">NBrightInfo class of PRD type</param>
        /// <param name="width">width</param>
        /// <param name="height">height</param>
        /// <param name="idx">index of the image to display</param>
        /// <param name="attributes">free text added onto end of url parameters</param>
        /// <returns>Thumbnailer url</returns>
        public IEncodedString ProductImage(NBrightInfo info, string width = "150", string height = "0", string idx = "1", string attributes = "", bool fileImage = false, bool outputPNG = false)
        {
            var url         = "";
            var imageurlsrc = info.GetXmlProperty("genxml/imgs/genxml[" + idx + "]/hidden/imageurl");

            if (fileImage)
            {
                var src = HttpContext.Current.Server.MapPath(imageurlsrc);

                var strCacheKey = info.PortalId + "*" + src + "*" + Utils.GetCurrentCulture() + "*imgfile:" + width + "*" + height + "*";
                url = (String)Utils.GetCache(strCacheKey);

                if (String.IsNullOrEmpty(url))
                {
                    var imgpath = Path.GetFileNameWithoutExtension(src);
                    var ext     = ".jpg";
                    if (outputPNG)
                    {
                        ext = ".png";
                    }
                    var thumbname = imgpath + "_Thumb" + width + "x" + height + ext;
                    imgpath = Path.GetFullPath(src).Replace(Path.GetFileName(src), "") + thumbname;
                    url     = imageurlsrc.Replace(Path.GetFileName(src), thumbname);

                    if (!File.Exists(imgpath))
                    {
                        var            newImage = ImgUtils.CreateThumbnail(src, Convert.ToInt32(width), Convert.ToInt32(height));
                        ImageCodecInfo useEncoder;
                        useEncoder = ImgUtils.GetEncoder(ImageFormat.Jpeg);
                        if (outputPNG)
                        {
                            useEncoder = ImgUtils.GetEncoder(ImageFormat.Png);
                        }

                        var encoderParameters = new EncoderParameters(1);
                        encoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 85L);

                        try
                        {
                            newImage.Save(imgpath, useEncoder, encoderParameters);
                        }
                        catch (Exception exc)
                        {
                            if (StoreSettings.Current.DebugMode)
                            {
                                url = exc.ToString();
                            }
                        }
                    }

                    if (!StoreSettings.Current.DebugMode)
                    {
                        Utils.SetCache(strCacheKey, url);
                    }
                }
            }
            else
            {
                url = StoreSettings.NBrightBuyPath() + "/NBrightThumb.ashx?src=" + imageurlsrc + "&w=" + width + "&h=" + height + attributes;
            }
            return(new RawString(url));
        }