I have submit the coe for image resizing using dotnet.I need convert this methodology to PHP.Please anybody one help me.
Private Shared Function ResizeImageFile(ByVal imageFile() As Byte, ByVal targetSize As Integer) As Byte()
Using oldImage As System.Drawing.Image = System.Drawing.Image.FromStream(New MemoryStream(imageFile))
Dim newSize As Size = CalculateDimensions(oldImage.Size, targetSize)
Using newImage As Bitmap = New Bitmap(newSize.Width, newSize.Height, PixelFormat.Format24bppRgb)
Using canvas As Graphics = Graphics.FromImage(newImage)
canvas.SmoothingMode = SmoothingMode.AntiAlias
canvas.InterpolationMode = InterpolationMode.HighQualityBicubic
canvas.PixelOffsetMode = PixelOffsetMode.HighQuality
canvas.DrawImage(oldImage, New Rectangle(New Point(0, 0), newSize))
Dim m As New MemoryStream
newImage.Save(m, ImageFormat.Jpeg)
Return m.GetBuffer
End Using
End Using
End Using
End Function
Private Shared Function CalculateDimensions(ByVal oldSize As Size, ByVal targetSize As Integer) As Size
Dim newSize As Size
If (oldSize.Height > oldSize.Width) Then
newSize.Width = CType((oldSize.Width * CType((targetSize / CType(oldSize.Height, Single)), Single)), Integer)
newSize.Height = targetSize
Else
newSize.Width = targetSize
newSize.Height = CType((oldSize.Height * CType((targetSize / CType(oldSize.Width, Single)), Single)), Integer)
End If
Return newSize
End Function
Image resizing
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
I don't know... rewrite it.
Use the GD Library. It's generally friendly for simple things like resizing. You may want too look at the imagecreate*() functions, the imagecopyresampled() function, and the image*() functions.
Use the GD Library. It's generally friendly for simple things like resizing. You may want too look at the imagecreate*() functions, the imagecopyresampled() function, and the image*() functions.