Wow, I was looking for a little tutorial and instead I get sample code... Thank 
you very much; I hope I can repay the favor someday.  

Travis D. Falls | Consultant   RAFT.Net   IT | 860.547.4070 | [EMAIL PROTECTED]


-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED]
Sent: Thursday, November 10, 2005 9:13 PM
To: [email protected]
Subject: RE: [AspNetAnyQuestionIsOk] Resize Images


For what it's worth, here's the function my picture manager app uses to process 
uploaded images.

Summary: The parameter is the full path to the uploaded image. The function 
creates the following:
    1) A copy of the image (known as the SOURCE IMAGE)
    2) A "base" image (basically a mid-size image no greater than 500x428 pixel 
dimensions)

    3) A thumbnail (no greater than 150x150 pixel dimensions

 

Hope it helps!

 

M.

 

Public Function ProcessImageFile(ByVal ProcessFilePath As String)

        'ORIGINAL IMAGE

        Dim ProcessFileName As String = Path.GetFileName(ProcessFilePath)

        Dim ProcessImage As System.Drawing.Image

        'SOURCE IMAGE

        Dim SourceFileName As String = "(SOURCE_" & ImageID & ") " & 
ProcessFileName

        Dim SourceFilePath As String = SourcePath & SourceFileName

        'BASE IMAGE

        Dim BaseFileName As String = "(BASE_" & ImageID & ") " & ProcessFileName

        Dim BaseFilePath As String = BasePath & BaseFileName

        'THUMB IMAGE

        Dim ThumbFileName As String = "(THUMB_" & ImageID & ") " & 
ProcessFileName

        Dim ThumbFilePath As String = ThumbPath & ThumbFileName

        Dim ThumbImage As System.Drawing.Image

 

        'CREATE SOURCE IMAGE

        File.Copy(ProcessFilePath, SourceFilePath)

 

        'OPEN PROCESS FILE

        ProcessImage = ProcessImage.FromFile(ProcessFilePath)

 

        'CREATE BASE IMAGE

        Dim inp As New System.IntPtr

        Dim BaseImageWidth As Integer

        Dim BaseImageHeight As Integer

        Dim BaseImageNewHeight As Integer

        BaseImageWidth = ProcessImage.Width

        BaseImageHeight = ProcessImage.Height

        If BaseImageWidth > 500 Then

            BaseImageWidth = 500

            BaseImageHeight = ProcessImage.Height * BaseImageWidth / 
ProcessImage.Width

        End If

        If BaseImageHeight > 428 Then

            BaseImageNewHeight = 428

            BaseImageWidth = BaseImageWidth * BaseImageNewHeight / 
BaseImageHeight

            BaseImageHeight = 428

        End If

 

        Dim BaseImageBitmap As New Bitmap(BaseImageWidth, BaseImageHeight, 
ProcessImage.PixelFormat.Format24bppRgb)

        Dim BaseImageGraphics As Graphics = Graphics.FromImage(BaseImageBitmap)

        BaseImageGraphics.DrawImage(ProcessImage, 0, 0, BaseImageBitmap.Width, 
BaseImageBitmap.Height)

        BaseImageBitmap.Save(BaseFilePath, ProcessImage.RawFormat)

        BaseImageGraphics.Dispose()

        BaseImageGraphics = Nothing

        BaseImageBitmap.Dispose()

        BaseImageBitmap = Nothing

        'CREATE THUMBNAIL

        If BaseImageWidth > 150 Then

            BaseImageWidth = 150

            BaseImageHeight = ProcessImage.Height * BaseImageWidth / 
ProcessImage.Width

        End If

        If BaseImageHeight > 150 Then

            BaseImageNewHeight = 150

            BaseImageWidth = BaseImageWidth * BaseImageNewHeight / 
BaseImageHeight

            BaseImageHeight = 150

        End If

        ThumbImage = ProcessImage.GetThumbnailImage(BaseImageWidth, 
BaseImageHeight, Nothing, inp)

        ThumbImage.Save(ThumbFilePath, ProcessImage.RawFormat)

 

        'RELEASE FILES

        ProcessImage.Dispose()

        ProcessImage = Nothing

        ThumbImage.Dispose()

        ThumbImage = Nothing

End Function

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf 
Of Falls, Travis D (HTSC, CASD)
Sent: Thursday, November 10, 2005 9:43 AM
To: [email protected]
Subject: [AspNetAnyQuestionIsOk] Resize Images

 

I would like to write or find an open source a modular in C# that looks at a 
directory and takes all the images in it and creates thumbnails, mediums, and 
large equivalents.  Does anyone have any advice, links, thoughts?  Basically I 
am tired of resizing images I put up on the web.  I want to build a photo album 
type of mod but I have seen any that do this simply.  Thanks.

Travis D. Falls | Consultant   RAFT.Net   IT | 860.547.4070 | [EMAIL PROTECTED]


*************************************************************************
This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information.  If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution is
strictly prohibited.  If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
*************************************************************************




________________________________

YAHOO! GROUPS LINKS 

 

*        Visit your group "AspNetAnyQuestionIsOk 
<http://groups.yahoo.com/group/AspNetAnyQuestionIsOk> " on the web.
          
*        To unsubscribe from this group, send an email to:
         [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
          
*        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service 
<http://docs.yahoo.com/info/terms/> . 

 

________________________________



[Non-text portions of this message have been removed]




 
Yahoo! Groups Links



 




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to