expo-pixi
expo-pixi copied to clipboard
Error: Expected URL scheme 'http' or 'https' but was 'file'
I'm trying to use expo-pixi to read out the color of the background (really the top left pixel) of an image. The image is hosted on a https://
url.
I'm doing this:
async getBackgroundColor(imageUri) {
const context = await GLView.createContextAsync()
const app = new PIXI.Application({ context })
console.log('[PIXI] loading', imageUri)
const sprite = await PIXI.Sprite.fromExpoAsync(imageUri)
console.log('[PIXI] sprite', sprite)
app.stage.addChild(sprite)
const pixels = app.renderer.extract.pixels(sprite)
console.log('[PIXI] extracted pixels', pixels.length)
const [r, g, b, a] = pixels.slice(0, 4)
console.log('[PIXI] loaded pixels', [r, g, b, a])
return `rgba(${r}, ${g}, ${b}, ${a})`
}
Unfortunately, the call PIXI.Sprite.fromExpoAsync(imageUri)
throws an error:
Error: Expected URL scheme 'http' or 'https' but was 'file'
I have looked through the documentation as well as reading through the issues and some of the code, it seems as if the exception comes from a lower level, but how is fromExpoAsync
supposed to be used? Is it possible to use remote resources? Should I use another API?
See this snack: https://snack.expo.io/@fredrikschweinebarth/8ac094
It seems as if this is because of a bug in expo-asset-utils: https://github.com/expo/expo-asset-utils/issues/18
Have you managed to solve this problem? I had the same issue when loading a texture from remote url.