locked
Dynamic Thumbnail generator RRS feed

  • Question

  • User-1636028287 posted

    Hi ,

     Its common need to show images of one product in different imag sizes like 50X50 ,80X80 and even 500X500. So some people use to save thumbnails in different width and heights at the time of uploading.

     Is  this possible that we can use following syntax to generate thumbnail?

    <img border="0"  src="http://mywebisteurl/thumbnail.aspx?pic=uplimg/img.gif&w=80&sq=Y&/> (I have seen some website's html and it was from there)

    The things to notice are in the source attribute of Img tag.  I am giving  address of my page which will generate thumbnail of width  ' w =80' and then I am specifying 'sq=Y'  which means that it should be of square type i-e width==height)

     I don't know what should I do in thumbnail.aspx page and how to return image. Please help me in how to generate best thumbnail and how to use them  

    Any help will be more then welcome.

    Regards,

    Wednesday, July 23, 2008 5:25 AM

Answers

  • User541108374 posted

    Hi,

    take a look at this code: http://west-wind.com/weblog/posts/283.aspx.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 23, 2008 7:24 AM
  • User541108374 posted

    Hi,

    does test.aspx, when you call it directly in your browser with that querystring return something? If not place breakpoints in the code and see where things don't return anything anymore. This is a job that you'll have to perform first.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 23, 2008 9:06 AM

All replies

  • User541108374 posted

    Hi,

    take a look at this code: http://west-wind.com/weblog/posts/283.aspx.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 23, 2008 7:24 AM
  • User-1636028287 posted

    Hi Grz, Kris, Thanks for the reply. Please cay you guide me how to call this code . I made a test.aspx page and copied code from  http://west-wind.com/weblog/posts/283.aspx. Then I am trying to call test.aspx page (responsible for returning thumbnail) from default.aspx as follows as follows

    In Default.aspx

    <img border="0" src="test.aspx?Image=images/Pic2.jpg&size=400&"/>.

    But no result is returned...

    Regards,

    Wednesday, July 23, 2008 8:29 AM
  • User-1636028287 posted

    Hi,

    A quick one ...I am able to call the test.aspx from default.aspx page. I dont know why it was not calling earlier.I didnt changed anything but again rebuild and it started calling test.aspx. But I am having problem that everytime I get the same Image size from test.aspx.

    <body>

    <form id="form1" runat="server">

    <div>

    <img border="0" src="test.aspx?Image=images/Pic2.jpg&size=1000&"/> //[not 1000, it was just for checking but the actual image of 50X50 is returned everytime]

    </div>

    </form>

    </body>

    Wednesday, July 23, 2008 8:37 AM
  • User-1636028287 posted

    Hi ,

    the  method below is the cause. I think that the logic is that it only returns thumbnail if the requested thumbnail is of smaller size then that of original Image. However I want to get the thumbnail(or whatever it will be called) even if its of bigger size then that of original image.Please guide

    public static Bitmap CreateThumbnail(string lcFilename, int lnWidth, int lnHeight)

    {

    ...... 

    //*** If the image is smaller than a thumbnail just return it

    if (loBMP.Width < lnWidth && loBMP.Height < lnHeight)

    return loBMP;

    ....

    }

    Regards,

    Wednesday, July 23, 2008 8:43 AM
  • User541108374 posted

    Hi,

    does test.aspx, when you call it directly in your browser with that querystring return something? If not place breakpoints in the code and see where things don't return anything anymore. This is a job that you'll have to perform first.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 23, 2008 9:06 AM
  • User-1636028287 posted

    Hi,

    actually I am calling test.aspx from Default.aspx as follows

    <img border="0" src="test.aspx?Image=images/Pic2.jpg&size=50&"/> [remember this code is in Default.aspx].

    Also I can directly call test.aspx?Image=images/Pic2.jpg&size=50& the browser.

    I can successfully go into debug mode and further can go through all the coding in test.aspx.cs file.

    The Problem is that in the codebehind file (I copied from the website you mentioned) of test.aspx the CreateThumbnail(string lcFilename, int lnWidth, int lnHeight) method is having restriction that it only returns thumbnail if the requested Image is of smaller width and height then that of original image.

    Example: Consider we have a Original.jpg (of 100X100) in Images folder. Your mentioned example website code will always work fine if we request for thumbnail like 50X50 or BXB(wher B must be less then the orginal size(100X100) of Original.jpg ). But If we will request for 200X200 or anything greater then 100X100(original size) it will return original image.

    Now I want the functionlaty that if if ask for BXB image and B can be greater then Original Image evern then we should get image

    Hope you understand.

    Wednesday, July 23, 2008 9:31 AM
  • User-1636028287 posted

    Hi,

    Is there any one ....The code above is working fine if we want to generate thumbnail(i-e smaller image then the original one),But I also want to get a bigger image when required.The above code use to return original image if we request for a bigger image then itself. Please help

    Friday, July 25, 2008 9:47 AM