Fetch an image from an external server and convert to base64
Use an image on your local machine to convert to base64
Share a bytes.Buffer to the package to detect the mime type and convert the image to base64
Ability to set a failover image if desired image throws an error or does not exist.
Automatically converts urls with " " to %20. Note: If your target domain uses +, _, etc. for space indicators it is your responsibility to modify the url accordingly.
Correctly sets the base64 encoding type to the media type of the image. Example: data:image/jpeg;base64
imgbase64.SetDefaultImage("http://yourdomain.com/defaultimage.png") // Optional - If FromRemote fails it will return " "
// Fetch the image from a remote server
img := imgbase64.FromRemote("http://somedomain.com/animage.jpg")
// Use an image local to machine
img := imgbase64.FromLocal("test.png")
// Pass an image buffer to package
img := imgbase64.FromBuffer(b)
Better error detection. Websites with custom 404 pages will sometimes "succeed" as being images and the package will base64 the html content of that page.
Ability to use local images to convert to base64
Cache the Default Image only once during the lifetime of the application. Presently every failed image is repulled.
Deprecate NewImage
Allow use of DefaultImage with FromBuffer and FromLocal
FromRemote is a better named function that
presently calls NewImage which will be deprecated.
Function accepts an RFC compliant URL and returns
a base64 encoded result.