locked
Change image size through URL Parameter RRS feed

All replies

  • User753101303 posted

    Hi,

    By definition it's possible if the site is written to handle that. We would rather need some more details. This is a 3rd party site maybe ?

    You can resize using for example https://stackoverflow.com/questions/2319983/resizing-an-image-in-asp-net-without-losing-the-image-quality.

    Tuesday, June 11, 2019 8:25 AM
  • User-719153870 posted

    Hi  kengkit,

    As far as I know, if you want to modify the image according to the query string, I suggest you could try to use set the image tag’s width or height in the code-behind:
    Like below:
    Notice: This will only work on your own application, directly add the query string in the url will not affect the image size.

    ASPX:

    <div>
        <img id="img1" runat="server" src="files/bgllogin.jpg" />
    </div>
    

    Code-behind:

    protected void Page_Load(object sender, EventArgs e)
            {
                string width = Request.QueryString["width"];// Receive parameters when page load
                string height = Request.QueryString["height"];
                img1.Style["width"] = width+"px";// add style attribute to the image
                img1.Style["height"] = height+"px";
            }
    

    Origin image URL:

    Changed image URL:

    Best Regard,
    Yang Shen

    Tuesday, June 11, 2019 8:38 AM
  • User409696431 posted

    "Original Image Url
    http://www.yourdomain.com/example.jpg

    Is this possible to do that?
    http://www.yourdomain.com/example.jpg?width=200&height=200"

    It is not possible as you have presented it.

    You can change a displayed image size in a webpage by changing the height and width attributes in the <img> tag (this does not change the image itself, but asks the browser to resize it), and you can write code to do that based on values in a query string, but a direct link to an image, as you show above, is not a webpage.  It's the image file itself. 

    Was that really what you are asking?

    Wednesday, June 12, 2019 3:26 AM