base64編碼 怎么將base64編碼變?yōu)閡rl?
怎么將base64編碼變?yōu)閡rl?"http://2.使用Base64;# 獲取圖片文件的內(nèi)容$fileContents = file_get_contents($fileName)# 對圖片文件內(nèi)容進行Bas
怎么將base64編碼變?yōu)閡rl?
"http://2.使用Base64;# 獲取圖片文件的內(nèi)容$fileContents = file_get_contents($fileName)# 對圖片文件內(nèi)容進行Base64編碼$fileBase64 = base64_encode($fileContents)//a.使用img標簽輸出base64編碼的圖片(以下兩種形式均可)echo ""echo ""http://b.直接輸出圖片,但是要加image的header標簽//header("content-type:image/gif")//echo base64_decode($fileBase64)
JS截取圖片(img)標簽中一塊區(qū)域的內(nèi)容轉(zhuǎn)為base64編碼?
/**
* Convert an image
* to a base64 string
* @param {String} url
* @param {Function} callback
* @param {String} [outputFormat=image/png]
*/
function convertImgToBase64(url, callback, outputFormat){
var canvas = document.createElement("CANVAS"),
ctx = canvas.getContext("2d"),
img = new Image
img.crossOrigin = "Anonymous"
img.onload = function(){
var dataURL
canvas.height = img.height
canvas.width = img.width
ctx.drawImage(img, 0, 0)
dataURL = canvas.toDataURL(outputFormat)
callback.call(this, dataURL)
canvas = null
}
img.src = url
}
這個方法試試吧?。。?!