0
我試圖將heic轉換爲jpg。我在js上使用official library。問題是我可以從存儲庫中解碼一張heic照片(回調函數返回一組數據),但是我無法解碼在iPhone上拍攝的heic照片(在這種情況下,回調函數根本沒有返回任何東西)。不能將iPhone heic照片轉換爲jpg
有沒有人試圖將iPhone上製作的heic照片轉換爲jpg格式?
var reader = new HEIFReader('test/1.heic');
var decoder = new HevcDecoder();
var imgData = new ImageProvider(reader, decoder);
reader.requestFileInfo(function(payload) {
if (payload.success !== true) {
console.error("Could not read file:", url);
} else {
var fileInfo = payload;
console.log("FileInfo contents:", fileInfo);
if (fileInfo.rootLevelMetaBoxProperties) {
var masterContextId = fileInfo.rootLevelMetaBoxProperties.contextId;
var masterItemIds = [];
var imageFeaturesMap = fileInfo.rootLevelMetaBoxProperties.imageFeaturesMap;
for (i in imageFeaturesMap) {
if (imageFeaturesMap.hasOwnProperty(i) && imageFeaturesMap[i].isMasterImage === true) {
masterItemIds.push(parseInt(i));
}
}
console.log("Master images in the file:", masterItemIds);
imgData.requestImageData(masterContextId, masterItemIds, function(data) {
console.log(data);
});
}
}
});