Forum Moderators: open
Image_width - returns the width in pixels of a specified image file
Image_height - returns the height
Scale_image - Scales the image of a specified image file to an absolute value or a percentage, and delivers the resulting modified image. The original file is unaltered.
Rotate_image - rotates the image a specified number of degrees.
Flip_image - flips image horizontally or vertically.
I have scanned through the functions documents but I have never seen any image functions.
Any ideas?
Thanks,
Imports System.Drawing.Imaging
...
uploadImage = System.Drawing.Image.FromStream(ImageUpload.PostedFile.InputStream)
...
Private Function CreatePicture(ByVal ImageUpload As System.Drawing.Image) As Boolean
dim startingPath ="whatever"
Dim lngWidth As Long
Dim lngHeight As Long
Dim IntX As IntPtr = New IntPtr()
' Obtain Image Object Reference from Uploaded Filestream
Dim uploadImage As System.Drawing.Image
Dim resizedImage As System.Drawing.Image
lngWidth = ImageUpload.Width
lngHeight = ImageUpload.Height
Dim intWidth As Integer
Dim intHeight As Integer
If lngHeight / lngWidth < 1 Then
'horizontal
intWidth = 300
intHeight = CInt(300 * lngHeight / lngWidth)
Else
'vertical
intWidth = CInt(300 * lngWidth / lngHeight)
intHeight = 300
End If
If boolFirst Then
End If
'get thumb
Dim intThWidth As Integer = CInt(66 * lngWidth / lngHeight)
If intThWidth < 120 Then
resizedImage = ImageUpload.GetThumbnailImage(intThWidth, 66, Nothing, IntX)
Else
resizedImage = ImageUpload.GetThumbnailImage(120, CInt(120 * lngHeight / lngWidth), Nothing, IntX)
End If
'now you can rotate it
resizedImage.RotateFlip(RotateFlipType.Rotate90FlipX) 'lets rotate it
resizedImage.Save(startingPath + "\thumbs\Picture.jpg", ImageFormat.Jpeg)
'save picture
Dim thumb As Bitmap = New Bitmap(ImageUpload, New Size(intWidth, intHeight))
thumb.Save(startingPath + "\pictures\thumb.jpg", ImageFormat.Jpeg)
CreatePicture = True
......
You can do prety much the same in ASP with ASPImage
reference
[p2p.wrox.com...]
I've used it and it's excellent - pure ASP (no components) to determine size, height, width and colour depth of images.
It won't of course help with rotating/flipping an image, but you may find it useful.
I think the problem with this approach is that this information is determined by the client after the fact. That is after the image is pushed to the users browser. I would like to manipulate the image before it is pushed across. In this way I'm not pushing big images only to shrink them down or alter them in some way.
I often have on original source image that I alter in various ways to present to the user. Right now I keep each and every version as a separate file. Of course this method is very reliable and fast, but it takes up a lot of disk space and it takes longer to create image sources.
Thanks,
I don't think my host is going go for putting a component on the server.
I wonder if a simple Java Applet would be the answer. In searching around I really can't find one that does just the basics as described. Plus I'm concerned about the speed.
If I could find one that simple resized and fliped images around both horizontal or vertical axis, I would be set.