无法将iPhone heic照片转换为jpg

时间:2017-10-21 10:05:03

标签: javascript image image-processing converter heif

我正在尝试将heic转换为jpg。我在js上使用official library。问题是我可以从存储库解码一张heic照片(回调返回一个数据数组),但我无法解码在iPhone上拍摄的照片(在这种情况下,回调根本不会返回任何内容)。

有没有人试图将iPhone上制作的照片转换成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);
      });

    }

  }
});

0 个答案:

没有答案