0
나는 이미지를 표시하는 TinyMCE에로 base64String를 내장하고있다 :큰 이미지의 경우 이미지에 포함 된 base64String이 길어 집니까?
<img src="blob:https://path/871bf236-3bae-472c-9f02-0bd3be19a435" alt="Desert.jpg" width="300" height="75" />
그것은 작은 이미지를 위해 작동하지만 그것은 큰 이미지에 관해서는 작동하지 않고 내가 추측하고 대형의 base64String가 포함 된 URL 때문에 이미지는 약 2,000 자라고 믿는 URL 브라우저 길이 제한에 부딪칩니다. 내 base64String을 줄이는 방법이 있는지 알고 싶습니까?
'File path of the attachment
DIM filePath = C:\path\solutions\Attachments\1\1726014c-7a2d-41b8-a79e-2acec1e8c7e0
'Converted base64String path
DIM base64URLPath = ToBase64String(ConvertToUrl(filePath)).toString
'Converts the path to a base64String
Public Function ToBase64String(filePath As String) As String
Dim aImage = New Bitmap(filePath)
Using stream = New IO.MemoryStream
Using img As Image = Image.FromFile(filePath)
If img.RawFormat.Equals(Imaging.ImageFormat.Jpeg) Then
aImage.Save(stream, Imaging.ImageFormat.Jpeg)
ElseIf img.RawFormat.Equals(Imaging.ImageFormat.Png) Then
aImage.Save(stream, Imaging.ImageFormat.Png)
ElseIf img.RawFormat.Equals(Imaging.ImageFormat.Icon) Then
aImage.Save(stream, Imaging.ImageFormat.Icon)
End If
End Using
Return Convert.ToBase64String(stream.ToArray)
End Using
End Function
'Gets the full file path
Public Function ConvertToUrl(filePath As String) As String
Dim uri = New Uri(filePath).LocalPath
Dim converted = uri
Return converted.ToString()
End Function