kleisauke / wasm-vips

libvips for the browser and Node.js, compiled to WebAssembly with Emscripten.
https://kleisauke.github.io/wasm-vips/
MIT License
510 stars 26 forks source link

Error `heifload: ignoring nclx profile` when converting to AVIF and resizing #62

Closed swissspidy closed 8 months ago

swissspidy commented 9 months ago

For some images such as https://github.com/swissspidy/media-experiments/blob/f6a7f9f26694b79a25ae2b844d2cc9a344d356a7/tests/e2e/assets/wordpress-logo-512x512.png I am getting this error when trying to convert to AVIF:

Screenshot 2024-01-18 at 22 53 30

Existing issues with same error:

Weird thing is that this is a PNG / AVIF situation, so not sure why HEIF would be involved here.

Here's a playground repro:

https://wasm-vips.kleisauke.nl/playground/?modules=jxl-heif&deflate=rVZtb9s2EP4rN3-RUjiSk2HA4MUJkGIBAgwoNnTYhzhAaekkc5BIjaTiuq3_-44UKdmak3hFAsSieC_P3XPHEx8mmRTaQCPK27YoUMEC2IZxA_HoWaDJ1jFEa2MaPU9TxTZJyc26XbUaFXkxKEySyTrVG661bni-TWvMOTvHzw0qXpNcpzXjIjWoaYmXmDKtkZYbqfJGodbnlSzl-U8Xl5_pP6GoIjiDs2RVyVVsF0wptu0ijc9-WYouevbEi1H4JHhCZe5rVuKdVDUzcZ_jYEiQbWV6I3rlX9DZxIPPKXyFDc_Neg4_zmZTWCMv18a_ZEo2cyhYpRF2UzCqRes-ANjAyb3ADdzaHB46xEfr02wbnEPELVxq4SLYDaFZyz__-I2M6TfJFDKDH1Z_Y2boPbbSQZfXJenlMmstyV751wrtW0wAZWR16ZlolZGm9017vU2Jxhvcbu_zOJKtaVoTEeNNgyJ_v-ZVHpOHLjmmtyKDohWZ4VIcI5u0zKqjzy7_aVnFzZawZ8nPl0txBl_tdgif7Ej0xBudOCcJEXanZO0rDZ0n6MCDmWwsuCZD52tpfp9DwHkHF1Qdu72zNsGiNX2bONBko7jBjzLgRImrw7T37RC9dd8svZukiytEVSETbXOTuM60OwpNq4Q3pL3dEe72e25EWieiJdCfrpky76nbKADXbiMS_8OGtaX2yuVGRAMT9Kzw_1LuIfwxCCcAdoFG7zhN4b7wCSVeh2v4gkomQz5BshhpfvtGs8av0w6Jzv67oOU29jLotv9yar2rXsl4Op4B8354QZA_BJE9yoTo6TvCEA27eiUYrw45mu7HMm6dHaAdDQ7JDgdYLPpYDgFDxG53sVfvG4iYsdOVxBFQSTNaK4x8Em8dqg-HinnHVdf2tgvBrFHQjLFPN_UaLkpXVqf7cU2VZlUlN5rcomKGxED9bdU1UgPlsOKmZg2VlkrmvEilaJ5Bbr8N2iXfp2T56nrgKjRFz1ToJF_8sNk3WGd3Par5oLY0NwcNsy-Z97jpgNs34dA9TnncZN8VyQtN7xI8jO5YIIeFewt2XufgaFTD8Xszdl4AfY24wM7bHhPnyg6gCgs7V2YexnWsO5qoovEpf4AZPO43sDeOw2fIxX9-wCOpp3B5WOIORNmsT8Z4HmFMkM2KqnZ6UheHgJ1tyMkXp4fsO-mZrFaSHNSnoryE8VzhOxvrNHbVo5kmm1DrjpL-LUTbTcaDa8eJl4jRbeW12wPN0A-i2kJGQxRYQYTDJ-f-k_2GCgmVFCVtrtAOVrpz5274nnDpmEwnVzl_Ap4vlpPuXrecXF-ltHe9FCSln8d_AQ

kleisauke commented 9 months ago

Hi @swissspidy,

It's safe to ignore this warning in this case. Upstream PR https://github.com/libvips/libvips/pull/3834 would remove this redundant warning.

Weird thing is that this is a PNG / AVIF situation, so not sure why HEIF would be involved here.

HEIF is a container, which supports HEVC and AV1 codecs used to create HEIC and AVIF images respectively. libvips leverages libheif to load/save these images.

swissspidy commented 9 months ago

Understood, thanks!

Is there a way to set the desired log level to hide info/warning/error messages?

kleisauke commented 9 months ago

The VIPS_WARNING environment variable is supposed to suppress these warning messages, for example:

const vips = await Vips({
  preRun: (module) => {
    // Hide warning messages
    module.ENV.VIPS_WARNING = 1;
  }
});

const im = vips.Image.newFromFile('x.avif');
im.writeToFile('x.png');

// Memory management
im.delete();

But, for some reason, it doesn't work for warnings emitted from side modules (i.e. vips-heif.wasm), which is curious.

I spent a couple of hours debugging to no avail, when I build wasm-vips without loadable modules, i.e.:

$ npm run build -- --disable-modules

The above program just works. :man_shrugging:

For now, I can recommend this workaround:

// Empty log handler
const log = (type, text) => void 0; // Or: console.log(`${type}: ${text}`);
const vips = await Vips({
  print: (text) => log('stdout', text),
  printErr: (text) => log('stderr', text),
});
kleisauke commented 8 months ago

v0.0.8 is now available and provides libvips v8.15.2.