Imagemagick and Streamlit

Basically I’m using moviepy which has some components that depends on imagemagick and although I am putting imagemagick in my packages.txt file, it is still bringing up this error:

File "/home/appuser/venv/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.dict)
File "/app/reddittotiktok/TikTok-Voice-TTS-main/frontend.py", line 28, in <module>
    make_video(subreddit, listing, limit, timeframe)
File "/app/reddittotiktok/TikTok-Voice-TTS-main/utils.py", line 256, in make_video
    word_subtitle_clips = generate_subtitle_clips(word_subtitles)
File "/app/reddittotiktok/TikTok-Voice-TTS-main/utils.py", line 244, in generate_subtitle_clips
    word_clip = TextClip(line, fontsize=24, color='white').set_duration(duration).set_position(('center', 'center'))
File "/home/appuser/venv/lib/python3.10/site-packages/moviepy/video/VideoClip.py", line 1146, in init
    raise IOError(error). 

I’m not quite sure what it means, but I think moviepy isn’t detecting imagemagick in streamlit. Also yes this does work on my local computer, I’m trying to put this on Streamlit cloud though. Also getting this in the terminal:

convert-im6.q16: attempt to perform an operation not allowed by the security policy @/tmp/tmpoyfdc8ce.txt' @ error/property.c/InterpretImageProperties/3708.

convert-im6.q16: no images defined PNG32:/tmp/tmpsok8w3pu.png' @ error/convert.c/ConvertImageCommand/3229.

This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect

Hi @RafaSarg, and welcome to our community! :raised_hands:

From your error log, it seems you’re having an issue with ImageMagick’s policies on Streamlit Cloud. Here’s the specific error:

convert-im6.q16: attempt to perform an operation not allowed by the security policy '@/tmp/tmpoyfdc8ce.txt' @ error/property.c/InterpretImageProperties/3708.

Have you checked Chanin’s suggestion here to fix this issue?

Best,
Charly

Hey @RafaSarg ,

Yeah, Streamlit does have security policies that prevent this.

I think your best approach now would be to have your Imagemagick image processing code up on a VM, another server or simply, your own api.

I think you could whip up a fast api or flask endpoint to handle this logic and use streamlit to make requests to this api.

This should help avoid you running into Streamlit’s client side security issues.

Let me know if this works!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.