Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageMagick not detected by moviepy while using SubtitlesClip #693

Closed
makelove opened this issue Jan 2, 2018 · 19 comments
Closed

ImageMagick not detected by moviepy while using SubtitlesClip #693

makelove opened this issue Jan 2, 2018 · 19 comments
Labels
lib-ImageMagick Issues pertaining to dependency ImageMagick. lib-misc Issues pertaining to misc. 3rd-party libraries.

Comments

@makelove
Copy link

makelove commented Jan 2, 2018

ubuntu 16.04
python3.6

  • Install
    apt-get -y install ffmpeg imagemagick

export FFMPEG_BINARY='/usr/bin/ffmpeg'
export IMAGEMAGICK_BINARY='/usr/bin/convert'

from moviepy.video.tools.subtitles import TextClip,SubtitlesClip

font="ArialUnicode"
color='white'
generator = lambda txt: TextClip(txt, font=font, fontsize=40, color=color)

subtitles = SubtitlesClip("big3.srt",generator)
  • Error
[MoviePy] This command returned an error !--------------------------------------------------------
OSError                Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/moviepy/video/VideoClip.py in __init__(self, txt, filename, size, color, bg_color, fontsize, font, stroke_color, stroke_width, method, kerning, align, interline, tempfilename, temptxt, transparent, remove_temp, print_cmd)
   1219         try:
-> 1220             subprocess_call(cmd, verbose=False )
   1221         except (IOError,OSError) as err:

/usr/local/lib/python3.6/dist-packages/moviepy/tools.py in subprocess_call(cmd, verbose, errorprint)
     48         verbose_print(errorprint, "\n[MoviePy] This command returned an error !")
---> 49         raise IOError(err.decode('utf8'))
     50     else:

OSError: convert: not authorized `@/tmp/tmpatq66tt_.txt' @ error/property.c/InterpretImageProperties/3405.
convert: no images defined `PNG32:/tmp/tmp4uy8drq2.png' @ error/convert.c/ConvertImageCommand/3210.


During handling of the above exception, another exception occurred:

OSError                Traceback (most recent call last)
<ipython-input-3-923a31c238ba> in <module>()
----> 1 subtitles = SubtitlesClip("big3.srt",generator)

/usr/local/lib/python3.6/dist-packages/moviepy/video/tools/subtitles.py in __init__(self, subtitles, make_textclip)
     84
     85         self.make_frame = make_frame
---> 86         hasmask = (self.make_textclip('T').mask is not None)
     87         self.mask = (VideoClip(make_mask_frame, ismask=True) if hasmask else None)
     88

<ipython-input-2-31100183c052> in <lambda>(txt)
      1 font="ArialUnicode"
      2 color='white'
----> 3 generator = lambda txt: TextClip(txt, font=font, fontsize=40, color=color)

/usr/local/lib/python3.6/dist-packages/moviepy/video/VideoClip.py in __init__(self, txt, filename, size, color, bg_color, fontsize, font, stroke_color, stroke_width, method, kerning, align, interline, tempfilename, temptxt, transparent, remove_temp, print_cmd)
   1227                     "path to the ImageMagick binary in file conf.py, or."
   1228                     "that the path you specified is incorrect" ))
-> 1229             raise IOError(error)
   1230
   1231         ImageClip.__init__(self, tempfilename, transparent=transparent)

OSError: MoviePy Error: creation of None failed because of the following error:

convert: not authorized `@/tmp/tmpatq66tt_.txt' @ error/property.c/InterpretImageProperties/3405.
convert: no images defined `PNG32:/tmp/tmp4uy8drq2.png' @ error/convert.c/ConvertImageCommand/3210.
.

.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

What should I do ?

@pkarp0
Copy link

pkarp0 commented Jan 4, 2018

Check for the ImageMagick policy file. ImageMagick does not have the proper permission set:
/etc/ImageMagick-6/policy.xml

@makelove
Copy link
Author

makelove commented Jan 5, 2018

@pkarp0 How to set up ?

<policymap>
  <!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
  <!-- <policy domain="resource" name="memory" value="2GiB"/> -->
  <!-- <policy domain="resource" name="map" value="4GiB"/> -->
  <!-- <policy domain="resource" name="area" value="1GB"/> -->
  <!-- <policy domain="resource" name="disk" value="16EB"/> -->
  <!-- <policy domain="resource" name="file" value="768"/> -->
  <!-- <policy domain="resource" name="thread" value="4"/> -->
  <!-- <policy domain="resource" name="throttle" value="0"/> -->
  <!-- <policy domain="resource" name="time" value="3600"/> -->
  <!-- <policy domain="system" name="precision" value="6"/> -->
  <policy domain="cache" name="shared-secret" value="passphrase"/>
  <policy domain="coder" rights="none" pattern="EPHEMERAL" />
  <policy domain="coder" rights="none" pattern="URL" />
  <policy domain="coder" rights="none" pattern="HTTPS" />
  <policy domain="coder" rights="none" pattern="MVG" />
  <policy domain="coder" rights="none" pattern="MSL" />
  <policy domain="coder" rights="none" pattern="TEXT" />
<policy domain="coder" rights="none" pattern="SHOW" />
  <policy domain="coder" rights="none" pattern="WIN" />
  <policy domain="coder" rights="none" pattern="PLT" />
  <policy domain="path" rights="none" pattern="@*" />
</policymap>

@pkarp0
Copy link

pkarp0 commented Jan 5, 2018

comment out (or remove the line that reads)
<policy domain="path" rights="none" pattern="@*" />

<!-- <policy domain="path" rights="none" pattern="@*" /> -->

@makelove
Copy link
Author

makelove commented Jan 6, 2018

Thank you !
it's Working.

No more error!

@pilgrim2go
Copy link

Thanks @pkarp0 works for me also

@nerdogram
Copy link

I am still getting this error even after removing the line? I am trying to run this on Google Colab. Any tips?

@pkarp0
Copy link

pkarp0 commented Jun 6, 2019

Havent worked with Colab. Try running ImageMagick directly. It is typically installed at /usr/bin/convert

@nerdogram
Copy link

I figured it out it had to be installed before importing moviepy

@kheniparth
Copy link

@alvisanovari Could you please tell me how you resolved it?

I tried to install ImageMagick in google colab even though it comes pre-installed like below but I am still getting permission issue.

!apt install imagemagick
!pip install -r requirements.txt

error:
convert-im6.q16: not authorized @/tmp/tmpqujkrvch.txt' @ error/property.c/InterpretImageProperties/3516. convert-im6.q16: no images defined PNG32:/tmp/tmpcewtbiuc.png' @ error/convert.c/ConvertImageCommand/3258..

.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

@nerdogram
Copy link

install imagemagic: ! apt install imagemagick
update the policy (see comments above about it)
then import

@kheniparth
Copy link

kheniparth commented Jul 21, 2019

Thank you for the reply @alvisanovari
Just for anyone else who also need it for Google Colab or the local machine. I have uploaded the policy file here : policy.xml

So just use wget command to get the file and put it at /etc/ImageMagick-6/policy.xml location

@rikhuijzer
Copy link

rikhuijzer commented May 2, 2020

The following code allows me to work with text via MoviePy from a fresh Google Colab instance.

!apt update &> /dev/null
!apt install imagemagick &> /dev/null
!apt install ffmpeg &> /dev/null
!pip3 install moviepy[optional] &> /dev/null
!sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml

Here sed is used to remove the line from the policy.xml file.

@flegascoin
Copy link

Thanks @pkarp0 you made my day too :-)

@Jonathan1045
Copy link

It was more useful than the answer of other website

@alexandernovateva
Copy link

Thank you so much @rikhuijzer that worked perfectly on my container 👍

@Saafke
Copy link

Saafke commented Aug 24, 2021

Check for the ImageMagick policy file. ImageMagick does not have the proper permission set:
/etc/ImageMagick-6/policy.xml

For what it's worth. When I did
cd /etc
ls
I could not find the ImageMagick-6 folder.

I had to do
cd /etc/ImageMagick-6
ls

Thanks for your help :)

@keikoro keikoro added the lib-ImageMagick Issues pertaining to dependency ImageMagick. label Oct 24, 2021
@adithya-s-k
Copy link

The following code allows me to work with text via MoviePy from a fresh Google Colab instance.

!apt update &> /dev/null
!apt install imagemagick &> /dev/null
!apt install ffmpeg &> /dev/null
!pip3 install moviepy[optional] &> /dev/null
!sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml

Here sed is used to remove the line from the policy.xml file.

Thank you so much

@johnnyvernin
Copy link

The following code allows me to work with text via MoviePy from a fresh Google Colab instance.

!apt update &> /dev/null
!apt install imagemagick &> /dev/null
!apt install ffmpeg &> /dev/null
!pip3 install moviepy[optional] &> /dev/null
!sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml

Here sed is used to remove the line from the policy.xml file.

Really Thanks!

@Stoppedwumm
Copy link

Working for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib-ImageMagick Issues pertaining to dependency ImageMagick. lib-misc Issues pertaining to misc. 3rd-party libraries.
Projects
None yet
Development

No branches or pull requests