如何将tiff图像数据(base64字符串tiff数据)转换为png数据?我尝试在gsp页面中预览tiff图像数据,但它不起作用。以下是在gsp页面中调用控制器和方法的代码:
<img src="${createLink(controller:'myController', action:'faxDocumentPreview')}"/>
以下是控制器中的代码:
def faxDocumentPreview(def decodedString){
def decodedFaxDocuments = decodedString
decodedFaxDocuments.each{
response.setHeader("Content-disposition", "attachment")
response.contentType = 'image/png'
OutputStream out = response.getOutputStream();
out.write(it)
out.close()
}
}
private def decodeFaxPreviews(def faxPreviews) {
def decodedFaxDocuments = []
faxPreviews.each {
decodedFaxDocuments.add(convertBase64ToTiff(it))
}
faxDocumentPreview(decodedFaxDocuments)
return decodedFaxDocuments
}
private def convertBase64ToTiff(def base64String) {
InputStream inputStream = FileStoreUtils.decodeBase64(base64String);
return inputStream
}