Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
blltest  
#1 Posted : Tuesday, March 31, 2009 11:30:21 AM(UTC)
blltest

Rank: Newbie

Groups: Member
Joined: 10/10/2008(UTC)
Posts: 2

I need to resize the thumbnail to a specific width regardless if the original is smaller or bigger. Is there a way to do this?
MyHuntSite  
#2 Posted : Tuesday, March 31, 2009 2:52:00 PM(UTC)
MyHuntSite

Rank: Newbie

Groups: Member
Joined: 3/18/2009(UTC)
Posts: 4

On the file upload you can get the thumbnail and resize it like so.

VB.NET:

Dim _orgThunbnail As System.Drawing.Image = System.Drawing.Image.FromStream(Request.Files("Thumbnail2_" & i).InputStream) ' used to hold the original image

'your fixed height and width

Dim thumb As New Bitmap(10, 10)

'Create a graphics object

Dim gr_dest As Graphics = Graphics.FromImage(thumb)

' just in case it's a transparent GIF force the bg to white if needed

Dim sb = New SolidBrush(System.Drawing.Color.White)

gr_dest.FillRectangle(sb, 0, 0, thumb.Width, thumb.Height)

'Re-draw the image to the specified height and width

gr_dest.DrawImage(_orgThunbnail, 0, 0, thumb.Width, thumb.Height)

'Save the image

_orgThunbnail.Save(Server.MapPath(upload_dir & newimagename & fileExt), originalimg.RawFormat)

I just wrote this code here and have not tested it, so it may need some tweaking if needed.

C# version

{

System.Drawing.Image _orgThunbnail = System.Drawing.Image.FromStream(Request.Files("Thumbnail2_" + i).InputStream);

// used to hold the original image

//your fixed height and width

Bitmap thumb = new Bitmap(10, 10);

//Create a graphics object

Graphics gr_dest = Graphics.FromImage(thumb);

// just in case it's a transparent GIF force the bg to white if needed

var sb = new SolidBrush(System.Drawing.Color.White);

gr_dest.FillRectangle(sb, 0, 0, thumb.Width, thumb.Height);

//Re-draw the image to the specified height and width

gr_dest.DrawImage(_orgThunbnail, 0, 0, thumb.Width, thumb.Height);

//Save the image

_orgThunbnail.Save(Server.MapPath(upload_dir + newimagename + fileExt), originalimg.RawFormat);

}

Edited by user Tuesday, March 31, 2009 2:56:39 PM(UTC)  | Reason: Not specified

Tamila  
#3 Posted : Wednesday, April 1, 2009 2:26:41 AM(UTC)
Tamila

Rank: Advanced Member

Groups:
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Also you can resize thumbnails using Graphics Mill.

Code:
'create bitmap
Dim thumbnail As New Aurigma.GraphicsMill.Bitmap(Request.Files("Thumbnail1_" & i)) 
'resize bitmap
thumbnail.Transforms.Resize(60, 60)
thumbnail.Save(Server.MapPath(upload_dir & "thumbnail" & i & ".jpg"))

You can get more information about Graphics Mill here:

About Graphics Mill

Edited by user Wednesday, April 1, 2009 2:30:17 AM(UTC)  | Reason: Not specified

Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.