Create image thumbnail in windows environment

i am using ffmpeg library for thumbnail image. My project runs in windows environment.
When executing the following code:

Thumbnex.create_thumbnail(url, new_url ,max_width: 64,max_height: 64)

I receive the following error in my code:

System.cmd("ffprobe", ["-show_format", "c:/Users/Salim/Desktop/Data/Elixir/Upload/d2e04a59-5fef-4f22-82d5-e0c6a1f25ea6.jpeg"], [stderr_to_stdout: true])
** (ErlangError) Erlang error: :enoent

ImageMagic and FFprobe installed on my system.

Are these in your %PATH%? Because that is how System.cmd/2 is looking for executables. Just installing them doesn’t necessarily add it to %PATH%.

1 Like

First try this:

System.cmd("ffprobe", ["--version"])

To make sure that it can indeed be invoked. If so then the :enoent error means that the file parameter you supplied in your OP does not exist.

1 Like

No, :enoent is only returned when the cmd wasn’t found.

If the cmd was found, and it was unable to find the file specified in its argument list, it has to communicate this fact through its exitcode, stout and stderr. You have access to the first 2 via the returned tuple then:

System.cmd("cat", ["this-file-does-not-exist"])
#=> {"", 1}

Of course, this is specific to cat, ffprobe might have a different exit code or output in this case.

1 Like

Good to know. Thank you. :+1: