Resize pictures, Email, Save and Delete big ones

4 posts, 1 answers
  1. Colstor
    Colstor avatar
    3 posts
    Member since:
    Jun 2007

    Posted 28 Jun 2013 Link to this post

    Hi,

    I dont know where to start on this so thought of posting it. Basically, I have to address all the following tasks.

    We have a large number of pictures which we send out to our customers on a regular basis. They get over sized and dont upload properly.

    I plan to make an application which re sizes and emails pictures.

    1) Select pictures with similar names ( first 5 digits) from some selected folder. May be on a button click.

    2) Re-size them to 200KB-400KB.

    3) Upload and Email them (Using Exchange). Email address is entered by user. Usually there would be around 20 pictures attached per email.

    4) Save those re-sized pictures to some drive.

    5) Delete the non-re-sized pictures which were selected.

    Could you please guide me little bit on what controls can I use?

    Thanks
  2. Answer
    SANJAY
    SANJAY avatar
    61 posts
    Member since:
    Jun 2012

    Posted 28 Jun 2013 Link to this post

    Hi

    I have written a small appliction in VB.net uses a couple of Telerik Win Form controls, this will compress the size of images and currently I have defined three parameters to compress

    a) Percentage of Size
    or
    b) Final Width
    or
    c) Final Height of Image


    It has two facilities
    a) Select a folder, then it creates a sub folder "Optimized" and the optimized images are save there
    b) Monitor a folder , then whenever a image is created i tne folder and application is running a optimized image is created in sub folder

    You could download the executable from
    http://www.thetaskmate.in/downloads/omzer/imgop.zip

    It will require dotnet Version 4.0

    Regards



    In case that works for you  I would give the source code
     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Colstor
    Colstor avatar
    3 posts
    Member since:
    Jun 2007

    Posted 29 Jun 2013 Link to this post

    Hello Sanjay,

    Thanks for the reply. I have download and ran the exe file.

    It does pretty much what I want (Excluding the auto email upload option).

    I like the application however I found out

     "Select the folder" doesn't work so I wasn't able to use process files button.

    I would surely love to use the application code to make it to the level that I can customize it to what I want.

    I would also want to convert it to Web application.

    Could you please post it? or email it to dweston1769@gmail.com

    Thanks.
  5. SANJAY
    SANJAY avatar
    61 posts
    Member since:
    Jun 2012

    Posted 29 Jun 2013 Link to this post

    The main code

    Dim upWidth As Integer = upBmp.Width
    Dim upHeight As Integer = upBmp.Height
    Dim newX As Integer = 0
    Dim newY As Integer = 0
    Dim reDuce As Decimal
    If Val(Redty) = 1 Then
        reDuce = Rval / 100
    ElseIf Val(Redty) = 2 Then
        reDuce = Val(Rval) / upWidth
    ElseIf Val(Redty) = 3 Then
        reDuce = Val(Rval) / upHeight
    Else
        MessageBox.Show("Enter the  Final Size of Image", "Image Optimizer")
        Exit Sub
    End If
     
    newHeight = upHeight * reDuce
    newWidth = upWidth * reDuce
    WRITEFILE(CStr(newHeight & " : " & newWidth))
    Dim newBmp As Bitmap = New Bitmap(newWidth, newHeight, Imaging.PixelFormat.Format24bppRgb)
    newBmp.SetResolution(72, 72)
    Dim newGraphic As Graphics = Graphics.FromImage(newBmp)
    Try
        newGraphic.Clear(Color.White)
     
        newGraphic.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
     
        newGraphic.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
     
        newGraphic.DrawImage(upBmp, newX, newY, newWidth, newHeight)
        If Len(WaterMark) > 0 Then
            Dim font As Font = New Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Pixel)
            Dim color As Color = color.FromArgb(transp, 0, 0, 0) '; //Adds a black watermark with a low alpha value (almost transparent).
            Dim atPoint As Point = New Point(100, 100)
            '   Point atPoint = new Point(100, 100); //The pixel point to draw the watermark at (this example puts it at 100, 100 (x, y)).
            Dim brush As SolidBrush = New SolidBrush(color)
     
            newGraphic.DrawString(WaterMark, font, brush, atPoint)
        End If
     
     
        If ext.ToLower = "png" Then
            newBmp.Save(filePath, Imaging.ImageFormat.Png)
        ElseIf ext.ToLower = "jpg" Then
            newBmp.Save(filePath, Imaging.ImageFormat.Jpeg)
        ElseIf ext.ToLower = "tif" Then
            newBmp.Save(filePath, Imaging.ImageFormat.Tiff)
        End If
     
        'filePath = Replace(filePath, ".png", ".jpg")
        'newBmp.Save(filePath, Imaging.ImageFormat.Jpeg)
        'filePath = Replace(filePath, ".jpg", ".tif")
        'newBmp.Save(filePath, Imaging.ImageFormat.Tiff)
Back to Top