Need Help Manipulating Images in ASP

Discussion in 'C#' started by Absilon, Dec 30, 2008.

  1. #1
    I am hoping someone here can help me with this issue.

    I need to take a 100X100 image and frame it in a larger image that is 124X119. The larger image needs to be on top of the smaller one with the smaller one being centered inside the larger image. I am basically taking a 100X100 thumbnail and creating a larger image out of it in which the original thumbnail is inside a frame.

    Any help at all would be greatly appreciated.

    By the way. I am running this website on a 64 bit Windows server.

    Thanks.
     
    Absilon, Dec 30, 2008 IP
  2. jhannell

    jhannell Member

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    hello,
    i recommend you to use PERSITS.JPEG product for manipulating images in asp.
     
    jhannell, Jan 2, 2009 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    You could do this fairly easily with ASP.NET. Below is some code:
    Imports System.Drawing

    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim bmp As New Bitmap(Server.MapPath("img1.jpg"))
            Dim bmp2 As New Bitmap(Server.MapPath("img2.jpg"))
            Dim g As Graphics
    
            g = Graphics.FromImage(bmp2)
            g.DrawImage(bmp, CInt((bmp2.Width - bmp.Width) / 2), CInt((bmp2.Height - bmp.Height) / 2))
    
            Response.ContentType = "image/jpeg"
            bmp2.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg)
    
            bmp.Dispose()
            bmp2.Dispose()
            g.Dispose()
            Response.End()
    
        End Sub
    
    Code (markup):
    The above code will center img1.jpg in img2.jpg.
    img2.jpg must be larger than img1.jpg
     
    camjohnson95, Jan 2, 2009 IP
  4. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #4
    if the images aren't already the right size they can be easily resized.
     
    camjohnson95, Jan 2, 2009 IP
  5. deltron

    deltron Active Member

    Messages:
    397
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    73
    #5
    Here is the image resizing code I use. I don't know about making the image larger though, you will loose quality no matter what you do. You can modify it to simplify, but using this you just input

     
    deltron, Jan 5, 2009 IP
  6. Absilon

    Absilon Peon

    Messages:
    158
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    camjohnson95 and deltron - Thank you very much for the code samples. I appreciate it very much.

    My entire web application is in classic ASP. Do you know if I can integrate a .net page into my asp site?
     
    Absilon, Jan 6, 2009 IP