2017-10-21 212 views
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); 
 
     }); 
 

 
    } 
 

 
    } 
 
});

回答