#Escaping image string path

21 messages · Page 1 of 1 (latest)

proud ermine
#

Hi,

I am getting image url path from json, I am trying to escape few characters and then use it as the image path. But I am getting the following error, can anyone please help
#let clean-string(linkPath)={
if linkPath!="" {
linkPath=linkPath.replace("/","")
}
return linkPath
}

#image("../../assets/"+clean-string(t.emojiLink), format: "png")

error screen shot is attached

mossy hatch
#

i mean

#

it seems to me that whatever clean-string is returning is a directory under assets

#

maybe it's even returning an empty string

#

replace #image with #panic to get an error showing the arguments passed

#

you will see what the resolved path is

proud ermine
#

@mossy hatch I am testing for empty string only

#

Imagine that t.emojiLink is empty

#

(if t.emojiLink.len()==0 {
[#text( weight: 100,fill: rgb(0,0,0,40%), size: 10pt, [-])]
}else{
[#image("../../assets/"+clean-string(t.emojiLink),  format: "png")]
})

#

I inted to show "-" if t.emoji is empty string otherwise pick that appropriate image from assets after cleaning the string, problem is in the above code, it is showing error that unexpected argument for clean-string concatenation

mossy hatch
#

without knowing which path it's trying to access but failing, we can't really know what's going on

proud ermine
#

Its actually picking the correct path, example - [#image(panic("../../assets/"+clean-string(t.emojiLink)),  format: "png")] error: panicked with: "../../assets/https:res.cloudinary.commeshimageuploadv1666776885avc_icons_v2Mini.png"

#

And the image is actually present in the path

#

But if I run the overall pdf I am getting this error

#

failed to decode image (Format error decoding Png: Unexpected end of data before image end.)

mossy hatch
#

That looks like a different error then

#

How did the error change ?

#

Either way, maybe your image is borked then

rotund breach
#

Try remove : from path

proud ermine
#

Ya @mossy hatch I regenerated the image, it worked