Thumbnailing graphics from a sister site

Discussion in 'ASP .Net' started by Blasting Cap, Nov 15, 2006.

  1. Blasting Cap

    Blasting Cap Guest

    I have to change the front page for a sales system I work on, and want
    to use some thumbnails of wallpaper that is on a sister site.

    The wallpapers are jpegs, and are 640, 800, 1024 & 1280 in size, and
    range from around 100k to about 2 megs.

    What I want to do is on my web page, keep the aspect ratio, but size
    them to be no more than 300 pixels wide.

    I've found some code to do this from a database, but can't find any that
    create thumbnails on the fly.

    Anyone know how to do this or have some code that'll do it?

    The source filename is:

    11_2006_640.jpg, 12_2006_640.jpg and so on.

    Any help appreciated.

    BC
    Blasting Cap, Nov 15, 2006
    #1
    1. Advertising

  2. Blasting Cap

    kferron Guest

    This is somewhat of a broad category. You are dealing with some
    efficiency issues if you are:

    (a) making a request to a server to retrieve the byte representation of
    the jpg
    (b) processing the image (the basic formula youre dealing with is
    calculating the new Height as:

    ratio = newWidth / currentWidth
    newHeight = currentHeight * r;

    (c) writing the newly created byte array to the output stream.


    To deal with issue (a), you will probably want to look at WebRequest

    To deal with issue(b), you will want to look at Bitmap class

    To deal with issue(c), you will want to look at Response, in that what
    you will be doing with the Bitmap in (b) is saving it to the output
    stream


    Make sure you're considering a proper caching strategy for this type of
    on the fly processing (ie. once you have a thumbnail from the sister
    site, hopefully you wouldn't need to resize it very often, if ever)

    ~kcf



    On Nov 15, 11:12 am, Blasting Cap <> wrote:
    > I have to change the front page for a sales system I work on, and want
    > to use some thumbnails of wallpaper that is on a sister site.
    >
    > The wallpapers are jpegs, and are 640, 800, 1024 & 1280 in size, and
    > range from around 100k to about 2 megs.
    >
    > What I want to do is on my web page, keep the aspect ratio, but size
    > them to be no more than 300 pixels wide.
    >
    > I've found some code to do this from a database, but can't find any that
    > create thumbnails on the fly.
    >
    > Anyone know how to do this or have some code that'll do it?
    >
    > The source filename is:
    >
    > 11_2006_640.jpg, 12_2006_640.jpg and so on.
    >
    > Any help appreciated.
    >
    > BC
    kferron, Nov 15, 2006
    #2
    1. Advertising

  3. Blasting Cap

    Blasting Cap Guest

    Is there any code doing part b available on the net? I had been doing
    some request servervariables in the code, and when I tried to do the
    webrequest, that made those stop working.



    kferron wrote:
    > This is somewhat of a broad category. You are dealing with some
    > efficiency issues if you are:
    >
    > (a) making a request to a server to retrieve the byte representation of
    > the jpg
    > (b) processing the image (the basic formula youre dealing with is
    > calculating the new Height as:
    >
    > ratio = newWidth / currentWidth
    > newHeight = currentHeight * r;
    >
    > (c) writing the newly created byte array to the output stream.
    >
    >
    > To deal with issue (a), you will probably want to look at WebRequest
    >
    > To deal with issue(b), you will want to look at Bitmap class
    >
    > To deal with issue(c), you will want to look at Response, in that what
    > you will be doing with the Bitmap in (b) is saving it to the output
    > stream
    >
    >
    > Make sure you're considering a proper caching strategy for this type of
    > on the fly processing (ie. once you have a thumbnail from the sister
    > site, hopefully you wouldn't need to resize it very often, if ever)
    >
    > ~kcf
    >
    >
    >
    > On Nov 15, 11:12 am, Blasting Cap <> wrote:
    >> I have to change the front page for a sales system I work on, and want
    >> to use some thumbnails of wallpaper that is on a sister site.
    >>
    >> The wallpapers are jpegs, and are 640, 800, 1024 & 1280 in size, and
    >> range from around 100k to about 2 megs.
    >>
    >> What I want to do is on my web page, keep the aspect ratio, but size
    >> them to be no more than 300 pixels wide.
    >>
    >> I've found some code to do this from a database, but can't find any that
    >> create thumbnails on the fly.
    >>
    >> Anyone know how to do this or have some code that'll do it?
    >>
    >> The source filename is:
    >>
    >> 11_2006_640.jpg, 12_2006_640.jpg and so on.
    >>
    >> Any help appreciated.
    >>
    >> BC

    >
    Blasting Cap, Nov 15, 2006
    #3
  4. Blasting Cap

    kferron Guest

    doing a quick search i found this article that would get you started
    http://west-wind.com/weblog/posts/283.aspx

    Blasting Cap wrote:
    > Is there any code doing part b available on the net? I had been doing
    > some request servervariables in the code, and when I tried to do the
    > webrequest, that made those stop working.
    >
    >
    >
    > kferron wrote:
    > > This is somewhat of a broad category. You are dealing with some
    > > efficiency issues if you are:
    > >
    > > (a) making a request to a server to retrieve the byte representation of
    > > the jpg
    > > (b) processing the image (the basic formula youre dealing with is
    > > calculating the new Height as:
    > >
    > > ratio = newWidth / currentWidth
    > > newHeight = currentHeight * r;
    > >
    > > (c) writing the newly created byte array to the output stream.
    > >
    > >
    > > To deal with issue (a), you will probably want to look at WebRequest
    > >
    > > To deal with issue(b), you will want to look at Bitmap class
    > >
    > > To deal with issue(c), you will want to look at Response, in that what
    > > you will be doing with the Bitmap in (b) is saving it to the output
    > > stream
    > >
    > >
    > > Make sure you're considering a proper caching strategy for this type of
    > > on the fly processing (ie. once you have a thumbnail from the sister
    > > site, hopefully you wouldn't need to resize it very often, if ever)
    > >
    > > ~kcf
    > >
    > >
    > >
    > > On Nov 15, 11:12 am, Blasting Cap <> wrote:
    > >> I have to change the front page for a sales system I work on, and want
    > >> to use some thumbnails of wallpaper that is on a sister site.
    > >>
    > >> The wallpapers are jpegs, and are 640, 800, 1024 & 1280 in size, and
    > >> range from around 100k to about 2 megs.
    > >>
    > >> What I want to do is on my web page, keep the aspect ratio, but size
    > >> them to be no more than 300 pixels wide.
    > >>
    > >> I've found some code to do this from a database, but can't find any that
    > >> create thumbnails on the fly.
    > >>
    > >> Anyone know how to do this or have some code that'll do it?
    > >>
    > >> The source filename is:
    > >>
    > >> 11_2006_640.jpg, 12_2006_640.jpg and so on.
    > >>
    > >> Any help appreciated.
    > >>
    > >> BC

    > >
    kferron, Nov 15, 2006
    #4
  5. Blasting Cap

    Blasting Cap Guest

    I've looked at the code there, but I don't know if I'm trying to do
    something that can't be easily done. All it ever does is hit the Catch
    in the Thumbnail routine.

    Here's the code I'm trying pull the image with:

    'Dim Image As String = Request.QueryString("Image")
    Dim Image As String = Session("filename")
    If Image Is Nothing Then
    Me.ErrorResult()
    Return
    End If

    Dim sSize As String = Request("Size")
    Dim Size As Integer = 120
    If Not sSize Is Nothing Then
    Size = Int32.Parse(sSize)
    End If

    'Dim Path As String = Server.MapPath(Request.ApplicationPath) +
    "\\" + Image
    Dim Path As String =
    Server.UrlPathEncode("http://www.mywebsite.com/images/library/downloads/wallpaper/"
    + Image)
    Dim bmp As Bitmap = CreateThumbnail(Path, Size, Size)

    If bmp Is Nothing Then
    Me.ErrorResult()
    Return
    End If

    Dim OutputFilename As String = Nothing
    OutputFilename = Request.QueryString("OutputFilename")

    If Not OutputFilename Is Nothing Then
    If Me.User.Identity.Name = "" Then
    ' *** Custom error display here
    bmp.Dispose()
    Me.ErrorResult()
    End If
    Try
    bmp.Save(OutputFilename)
    Catch ex As Exception
    bmp.Dispose()
    Me.ErrorResult()
    Return
    End Try
    End If

    ' Put user code to initialize the page here
    Response.ContentType = "image/jpeg"
    bmp.Save(Response.OutputStream,
    System.Drawing.Imaging.ImageFormat.Jpeg)
    bmp.Dispose()


    The only thing I'm doing differently is creating the filename, and then
    where it's looking for a path, I'm giving it a URL.

    The other two pieces of code (CreateThumbnail & the Errorresult) are as
    they were:

    Public Shared Function CreateThumbnail(ByVal lcFilename As String,
    ByVal lnWidth As Integer, ByVal lnHeight As Integer) As Bitmap

    Dim bmpOut As System.Drawing.Bitmap = Nothing
    Try
    Dim loBMP As Bitmap = New Bitmap(lcFilename)
    Dim loFormat As ImageFormat = loBMP.RawFormat

    Dim lnRatio As Decimal
    Dim lnNewWidth As Integer = 0
    Dim lnNewHeight As Integer = 0

    '*** If the image is smaller than a thumbnail just return it
    If loBMP.Width < lnWidth And loBMP.Height < lnHeight Then
    Return loBMP
    End If

    If loBMP.Width > loBMP.Height Then
    lnRatio = CType(lnWidth / loBMP.Width, Decimal)
    lnNewWidth = lnWidth
    Dim lnTemp As Decimal = loBMP.Height * lnRatio
    lnNewHeight = CType(lnTemp, Integer)
    Else
    lnRatio = CType(lnHeight / loBMP.Height, Decimal)
    lnNewHeight = lnHeight
    Dim lnTemp As Decimal = loBMP.Width * lnRatio
    lnNewWidth = CType(lnTemp, Integer)
    End If

    ' System.Drawing.Image imgOut =
    ' loBMP.GetThumbnailImage(lnNewWidth,lnNewHeight,
    ' null,IntPtr.Zero);


    ' *** This code creates cleaner (though bigger) thumbnails
    and properly
    ' *** and handles GIF files better by generating a white
    background for
    ' *** transparent images (as opposed to black)
    bmpOut = New Bitmap(lnNewWidth, lnNewHeight)
    Dim g As Graphics = Graphics.FromImage(bmpOut)
    g.InterpolationMode =
    System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
    g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight)
    g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight)

    loBMP.Dispose()
    Catch
    Return Nothing
    End Try

    Return bmpOut

    End Function


    Private Sub ErrorResult()
    Response.Clear()
    Response.StatusCode = 404
    Response.End()
    End Sub

    All I really want to do is to put a thumbnail of a mm_yyyy_640.jpg
    wallpaper from a sister site into a cell of a table as it's displayed on
    the front page of my sales info website.

    I'd appreciate any assistance in helping me figure out what's wrong with
    what I'm trying to do?


    BC





    kferron wrote:
    > doing a quick search i found this article that would get you started
    > http://west-wind.com/weblog/posts/283.aspx
    >
    > Blasting Cap wrote:
    >> Is there any code doing part b available on the net? I had been doing
    >> some request servervariables in the code, and when I tried to do the
    >> webrequest, that made those stop working.
    >>
    >>
    >>
    >> kferron wrote:
    >>> This is somewhat of a broad category. You are dealing with some
    >>> efficiency issues if you are:
    >>>
    >>> (a) making a request to a server to retrieve the byte representation of
    >>> the jpg
    >>> (b) processing the image (the basic formula youre dealing with is
    >>> calculating the new Height as:
    >>>
    >>> ratio = newWidth / currentWidth
    >>> newHeight = currentHeight * r;
    >>>
    >>> (c) writing the newly created byte array to the output stream.
    >>>
    >>>
    >>> To deal with issue (a), you will probably want to look at WebRequest
    >>>
    >>> To deal with issue(b), you will want to look at Bitmap class
    >>>
    >>> To deal with issue(c), you will want to look at Response, in that what
    >>> you will be doing with the Bitmap in (b) is saving it to the output
    >>> stream
    >>>
    >>>
    >>> Make sure you're considering a proper caching strategy for this type of
    >>> on the fly processing (ie. once you have a thumbnail from the sister
    >>> site, hopefully you wouldn't need to resize it very often, if ever)
    >>>
    >>> ~kcf
    >>>
    >>>
    >>>
    >>> On Nov 15, 11:12 am, Blasting Cap <> wrote:
    >>>> I have to change the front page for a sales system I work on, and want
    >>>> to use some thumbnails of wallpaper that is on a sister site.
    >>>>
    >>>> The wallpapers are jpegs, and are 640, 800, 1024 & 1280 in size, and
    >>>> range from around 100k to about 2 megs.
    >>>>
    >>>> What I want to do is on my web page, keep the aspect ratio, but size
    >>>> them to be no more than 300 pixels wide.
    >>>>
    >>>> I've found some code to do this from a database, but can't find any that
    >>>> create thumbnails on the fly.
    >>>>
    >>>> Anyone know how to do this or have some code that'll do it?
    >>>>
    >>>> The source filename is:
    >>>>
    >>>> 11_2006_640.jpg, 12_2006_640.jpg and so on.
    >>>>
    >>>> Any help appreciated.
    >>>>
    >>>> BC

    >
    Blasting Cap, Nov 16, 2006
    #5
  6. Blasting Cap

    kferron Guest

    What you're missing is you can't pass the path like that, you need to
    get a file stream of the image youre grabbing

    Blasting Cap wrote:
    > I've looked at the code there, but I don't know if I'm trying to do
    > something that can't be easily done. All it ever does is hit the Catch
    > in the Thumbnail routine.
    >
    > Here's the code I'm trying pull the image with:
    >
    > 'Dim Image As String = Request.QueryString("Image")
    > Dim Image As String = Session("filename")
    > If Image Is Nothing Then
    > Me.ErrorResult()
    > Return
    > End If
    >
    > Dim sSize As String = Request("Size")
    > Dim Size As Integer = 120
    > If Not sSize Is Nothing Then
    > Size = Int32.Parse(sSize)
    > End If
    >
    > 'Dim Path As String = Server.MapPath(Request.ApplicationPath) +
    > "\\" + Image
    > Dim Path As String =
    > Server.UrlPathEncode("http://www.mywebsite.com/images/library/downloads/wallpaper/"
    > + Image)
    > Dim bmp As Bitmap = CreateThumbnail(Path, Size, Size)
    >
    > If bmp Is Nothing Then
    > Me.ErrorResult()
    > Return
    > End If
    >
    > Dim OutputFilename As String = Nothing
    > OutputFilename = Request.QueryString("OutputFilename")
    >
    > If Not OutputFilename Is Nothing Then
    > If Me.User.Identity.Name = "" Then
    > ' *** Custom error display here
    > bmp.Dispose()
    > Me.ErrorResult()
    > End If
    > Try
    > bmp.Save(OutputFilename)
    > Catch ex As Exception
    > bmp.Dispose()
    > Me.ErrorResult()
    > Return
    > End Try
    > End If
    >
    > ' Put user code to initialize the page here
    > Response.ContentType = "image/jpeg"
    > bmp.Save(Response.OutputStream,
    > System.Drawing.Imaging.ImageFormat.Jpeg)
    > bmp.Dispose()
    >
    >
    > The only thing I'm doing differently is creating the filename, and then
    > where it's looking for a path, I'm giving it a URL.
    >
    > The other two pieces of code (CreateThumbnail & the Errorresult) are as
    > they were:
    >
    > Public Shared Function CreateThumbnail(ByVal lcFilename As String,
    > ByVal lnWidth As Integer, ByVal lnHeight As Integer) As Bitmap
    >
    > Dim bmpOut As System.Drawing.Bitmap = Nothing
    > Try
    > Dim loBMP As Bitmap = New Bitmap(lcFilename)
    > Dim loFormat As ImageFormat = loBMP.RawFormat
    >
    > Dim lnRatio As Decimal
    > Dim lnNewWidth As Integer = 0
    > Dim lnNewHeight As Integer = 0
    >
    > '*** If the image is smaller than a thumbnail just return it
    > If loBMP.Width < lnWidth And loBMP.Height < lnHeight Then
    > Return loBMP
    > End If
    >
    > If loBMP.Width > loBMP.Height Then
    > lnRatio = CType(lnWidth / loBMP.Width, Decimal)
    > lnNewWidth = lnWidth
    > Dim lnTemp As Decimal = loBMP.Height * lnRatio
    > lnNewHeight = CType(lnTemp, Integer)
    > Else
    > lnRatio = CType(lnHeight / loBMP.Height, Decimal)
    > lnNewHeight = lnHeight
    > Dim lnTemp As Decimal = loBMP.Width * lnRatio
    > lnNewWidth = CType(lnTemp, Integer)
    > End If
    >
    > ' System.Drawing.Image imgOut =
    > ' loBMP.GetThumbnailImage(lnNewWidth,lnNewHeight,
    > ' null,IntPtr.Zero);
    >
    >
    > ' *** This code creates cleaner (though bigger) thumbnails
    > and properly
    > ' *** and handles GIF files better by generating a white
    > background for
    > ' *** transparent images (as opposed to black)
    > bmpOut = New Bitmap(lnNewWidth, lnNewHeight)
    > Dim g As Graphics = Graphics.FromImage(bmpOut)
    > g.InterpolationMode =
    > System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
    > g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight)
    > g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight)
    >
    > loBMP.Dispose()
    > Catch
    > Return Nothing
    > End Try
    >
    > Return bmpOut
    >
    > End Function
    >
    >
    > Private Sub ErrorResult()
    > Response.Clear()
    > Response.StatusCode = 404
    > Response.End()
    > End Sub
    >
    > All I really want to do is to put a thumbnail of a mm_yyyy_640.jpg
    > wallpaper from a sister site into a cell of a table as it's displayed on
    > the front page of my sales info website.
    >
    > I'd appreciate any assistance in helping me figure out what's wrong with
    > what I'm trying to do?
    >
    >
    > BC
    >
    >
    >
    >
    >
    > kferron wrote:
    > > doing a quick search i found this article that would get you started
    > > http://west-wind.com/weblog/posts/283.aspx
    > >
    > > Blasting Cap wrote:
    > >> Is there any code doing part b available on the net? I had been doing
    > >> some request servervariables in the code, and when I tried to do the
    > >> webrequest, that made those stop working.
    > >>
    > >>
    > >>
    > >> kferron wrote:
    > >>> This is somewhat of a broad category. You are dealing with some
    > >>> efficiency issues if you are:
    > >>>
    > >>> (a) making a request to a server to retrieve the byte representation of
    > >>> the jpg
    > >>> (b) processing the image (the basic formula youre dealing with is
    > >>> calculating the new Height as:
    > >>>
    > >>> ratio = newWidth / currentWidth
    > >>> newHeight = currentHeight * r;
    > >>>
    > >>> (c) writing the newly created byte array to the output stream.
    > >>>
    > >>>
    > >>> To deal with issue (a), you will probably want to look at WebRequest
    > >>>
    > >>> To deal with issue(b), you will want to look at Bitmap class
    > >>>
    > >>> To deal with issue(c), you will want to look at Response, in that what
    > >>> you will be doing with the Bitmap in (b) is saving it to the output
    > >>> stream
    > >>>
    > >>>
    > >>> Make sure you're considering a proper caching strategy for this type of
    > >>> on the fly processing (ie. once you have a thumbnail from the sister
    > >>> site, hopefully you wouldn't need to resize it very often, if ever)
    > >>>
    > >>> ~kcf
    > >>>
    > >>>
    > >>>
    > >>> On Nov 15, 11:12 am, Blasting Cap <> wrote:
    > >>>> I have to change the front page for a sales system I work on, and want
    > >>>> to use some thumbnails of wallpaper that is on a sister site.
    > >>>>
    > >>>> The wallpapers are jpegs, and are 640, 800, 1024 & 1280 in size, and
    > >>>> range from around 100k to about 2 megs.
    > >>>>
    > >>>> What I want to do is on my web page, keep the aspect ratio, but size
    > >>>> them to be no more than 300 pixels wide.
    > >>>>
    > >>>> I've found some code to do this from a database, but can't find any that
    > >>>> create thumbnails on the fly.
    > >>>>
    > >>>> Anyone know how to do this or have some code that'll do it?
    > >>>>
    > >>>> The source filename is:
    > >>>>
    > >>>> 11_2006_640.jpg, 12_2006_640.jpg and so on.
    > >>>>
    > >>>> Any help appreciated.
    > >>>>
    > >>>> BC

    > >
    kferron, Nov 16, 2006
    #6
  7. Blasting Cap

    kferron Guest

    What you're missing is you can't pass the path like that, you need to
    get a file stream of the image youre grabbing

    Blasting Cap wrote:
    > I've looked at the code there, but I don't know if I'm trying to do
    > something that can't be easily done. All it ever does is hit the Catch
    > in the Thumbnail routine.
    >
    > Here's the code I'm trying pull the image with:
    >
    > 'Dim Image As String = Request.QueryString("Image")
    > Dim Image As String = Session("filename")
    > If Image Is Nothing Then
    > Me.ErrorResult()
    > Return
    > End If
    >
    > Dim sSize As String = Request("Size")
    > Dim Size As Integer = 120
    > If Not sSize Is Nothing Then
    > Size = Int32.Parse(sSize)
    > End If
    >
    > 'Dim Path As String = Server.MapPath(Request.ApplicationPath) +
    > "\\" + Image
    > Dim Path As String =
    > Server.UrlPathEncode("http://www.mywebsite.com/images/library/downloads/wallpaper/"
    > + Image)
    > Dim bmp As Bitmap = CreateThumbnail(Path, Size, Size)
    >
    > If bmp Is Nothing Then
    > Me.ErrorResult()
    > Return
    > End If
    >
    > Dim OutputFilename As String = Nothing
    > OutputFilename = Request.QueryString("OutputFilename")
    >
    > If Not OutputFilename Is Nothing Then
    > If Me.User.Identity.Name = "" Then
    > ' *** Custom error display here
    > bmp.Dispose()
    > Me.ErrorResult()
    > End If
    > Try
    > bmp.Save(OutputFilename)
    > Catch ex As Exception
    > bmp.Dispose()
    > Me.ErrorResult()
    > Return
    > End Try
    > End If
    >
    > ' Put user code to initialize the page here
    > Response.ContentType = "image/jpeg"
    > bmp.Save(Response.OutputStream,
    > System.Drawing.Imaging.ImageFormat.Jpeg)
    > bmp.Dispose()
    >
    >
    > The only thing I'm doing differently is creating the filename, and then
    > where it's looking for a path, I'm giving it a URL.
    >
    > The other two pieces of code (CreateThumbnail & the Errorresult) are as
    > they were:
    >
    > Public Shared Function CreateThumbnail(ByVal lcFilename As String,
    > ByVal lnWidth As Integer, ByVal lnHeight As Integer) As Bitmap
    >
    > Dim bmpOut As System.Drawing.Bitmap = Nothing
    > Try
    > Dim loBMP As Bitmap = New Bitmap(lcFilename)
    > Dim loFormat As ImageFormat = loBMP.RawFormat
    >
    > Dim lnRatio As Decimal
    > Dim lnNewWidth As Integer = 0
    > Dim lnNewHeight As Integer = 0
    >
    > '*** If the image is smaller than a thumbnail just return it
    > If loBMP.Width < lnWidth And loBMP.Height < lnHeight Then
    > Return loBMP
    > End If
    >
    > If loBMP.Width > loBMP.Height Then
    > lnRatio = CType(lnWidth / loBMP.Width, Decimal)
    > lnNewWidth = lnWidth
    > Dim lnTemp As Decimal = loBMP.Height * lnRatio
    > lnNewHeight = CType(lnTemp, Integer)
    > Else
    > lnRatio = CType(lnHeight / loBMP.Height, Decimal)
    > lnNewHeight = lnHeight
    > Dim lnTemp As Decimal = loBMP.Width * lnRatio
    > lnNewWidth = CType(lnTemp, Integer)
    > End If
    >
    > ' System.Drawing.Image imgOut =
    > ' loBMP.GetThumbnailImage(lnNewWidth,lnNewHeight,
    > ' null,IntPtr.Zero);
    >
    >
    > ' *** This code creates cleaner (though bigger) thumbnails
    > and properly
    > ' *** and handles GIF files better by generating a white
    > background for
    > ' *** transparent images (as opposed to black)
    > bmpOut = New Bitmap(lnNewWidth, lnNewHeight)
    > Dim g As Graphics = Graphics.FromImage(bmpOut)
    > g.InterpolationMode =
    > System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
    > g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight)
    > g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight)
    >
    > loBMP.Dispose()
    > Catch
    > Return Nothing
    > End Try
    >
    > Return bmpOut
    >
    > End Function
    >
    >
    > Private Sub ErrorResult()
    > Response.Clear()
    > Response.StatusCode = 404
    > Response.End()
    > End Sub
    >
    > All I really want to do is to put a thumbnail of a mm_yyyy_640.jpg
    > wallpaper from a sister site into a cell of a table as it's displayed on
    > the front page of my sales info website.
    >
    > I'd appreciate any assistance in helping me figure out what's wrong with
    > what I'm trying to do?
    >
    >
    > BC
    >
    >
    >
    >
    >
    > kferron wrote:
    > > doing a quick search i found this article that would get you started
    > > http://west-wind.com/weblog/posts/283.aspx
    > >
    > > Blasting Cap wrote:
    > >> Is there any code doing part b available on the net? I had been doing
    > >> some request servervariables in the code, and when I tried to do the
    > >> webrequest, that made those stop working.
    > >>
    > >>
    > >>
    > >> kferron wrote:
    > >>> This is somewhat of a broad category. You are dealing with some
    > >>> efficiency issues if you are:
    > >>>
    > >>> (a) making a request to a server to retrieve the byte representation of
    > >>> the jpg
    > >>> (b) processing the image (the basic formula youre dealing with is
    > >>> calculating the new Height as:
    > >>>
    > >>> ratio = newWidth / currentWidth
    > >>> newHeight = currentHeight * r;
    > >>>
    > >>> (c) writing the newly created byte array to the output stream.
    > >>>
    > >>>
    > >>> To deal with issue (a), you will probably want to look at WebRequest
    > >>>
    > >>> To deal with issue(b), you will want to look at Bitmap class
    > >>>
    > >>> To deal with issue(c), you will want to look at Response, in that what
    > >>> you will be doing with the Bitmap in (b) is saving it to the output
    > >>> stream
    > >>>
    > >>>
    > >>> Make sure you're considering a proper caching strategy for this type of
    > >>> on the fly processing (ie. once you have a thumbnail from the sister
    > >>> site, hopefully you wouldn't need to resize it very often, if ever)
    > >>>
    > >>> ~kcf
    > >>>
    > >>>
    > >>>
    > >>> On Nov 15, 11:12 am, Blasting Cap <> wrote:
    > >>>> I have to change the front page for a sales system I work on, and want
    > >>>> to use some thumbnails of wallpaper that is on a sister site.
    > >>>>
    > >>>> The wallpapers are jpegs, and are 640, 800, 1024 & 1280 in size, and
    > >>>> range from around 100k to about 2 megs.
    > >>>>
    > >>>> What I want to do is on my web page, keep the aspect ratio, but size
    > >>>> them to be no more than 300 pixels wide.
    > >>>>
    > >>>> I've found some code to do this from a database, but can't find any that
    > >>>> create thumbnails on the fly.
    > >>>>
    > >>>> Anyone know how to do this or have some code that'll do it?
    > >>>>
    > >>>> The source filename is:
    > >>>>
    > >>>> 11_2006_640.jpg, 12_2006_640.jpg and so on.
    > >>>>
    > >>>> Any help appreciated.
    > >>>>
    > >>>> BC

    > >
    kferron, Nov 16, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?aWFpbmZvZ2c=?=

    Can't load graphics in .NET 2.0 site

    =?Utf-8?B?aWFpbmZvZ2c=?=, Apr 7, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    1,871
    =?Utf-8?B?aWFpbmZvZ2c=?=
    Apr 7, 2006
  2. Jemdam.com
    Replies:
    10
    Views:
    578
    Jemdam.com
    Oct 26, 2005
  3. Guest
    Replies:
    0
    Views:
    322
    Guest
    Aug 11, 2003
  4. Replies:
    2
    Views:
    447
    Alvin
    Nov 24, 2005
  5. Raymond Brigleb

    RMagick Thumbnailing Question

    Raymond Brigleb, Sep 8, 2005, in forum: Ruby
    Replies:
    2
    Views:
    119
Loading...

Share This Page