10

I wanted to automate conversion from pdf to animated gif with animate rule provided by cmhughes in answer to plotting the sequence x_n using tikz.

I'm using arara+texworks+miktex on windows. I also have imagemagick installed and working from command line.

I've saved cmhughes code as animate.yaml in my \rules folder. I add

% arara: pdflatex
% arara: animate

to my tex file (as example, this pgfplots code) and compile it with arara. The result is a correct pdf file but when starts animate it shows a message with

Running animate ...

Parámetro no válido: 10
FAILURE

Parámetro no válido means non valid parameter and I don't know which program (arara, convert) shows it.

I'm using arara from TeXworks with options --log and --verbose. After compiling a tex file, arara.log contains:

05 Jun 2013 15:52:58.687 INFO  Arara - Welcome to arara!
05 Jun 2013 15:52:58.687 INFO  Arara - Processing file '117309.tex', please wait.
05 Jun 2013 15:52:58.703 INFO  DirectiveExtractor - Reading directives from 117309.tex.
05 Jun 2013 15:52:58.703 TRACE DirectiveExtractor - Directive found in line 1 with animate: {density: 200, delay: 10}.
05 Jun 2013 15:52:58.812 INFO  DirectiveParser - Parsing directives.
05 Jun 2013 15:52:58.812 INFO  TaskDeployer - Deploying tasks into commands.
05 Jun 2013 15:52:58.812 TRACE TaskDeployer - Task 'animate' found in 'D:\Archivos de programa\arara\rules'.
05 Jun 2013 15:52:59.125 INFO  CommandTrigger - Ready to run commands.
05 Jun 2013 15:52:59.125 INFO  CommandTrigger - Running 'animate'.
05 Jun 2013 15:52:59.125 TRACE CommandTrigger - Command: convert -delay 10 -loop 0 -density 200 "117309.pdf" "117309.gif"
05 Jun 2013 15:52:59.265 TRACE CommandTrigger - Output logging:
05 Jun 2013 15:52:59.265 TRACE CommandTrigger - Par metro no v lido: 10

05 Jun 2013 15:52:59.265 WARN  CommandTrigger - 'animate' returned an error status.
05 Jun 2013 15:52:59.265 INFO  Arara - Done.

(empty line is original, not my mistake editing it)

In any case, running command

convert -delay 10 -loop 0 -density 300 myfile.pdf myfile.gif

from command window works and creates a gif file. This command is what it's trying to do arara: animate.

Do you know what's wrong?

Ignasi
  • 136,588
  • Did you try to add the flags -v -l to the compilation of arara. Then you have a verbosed arara log file. – Marco Daniel Jun 05 '13 at 11:06
  • @MarcoDaniel Nothing changes. I've added arara.log results. – Ignasi Jun 05 '13 at 13:59
  • Please add the option -debug All to convert. Then you get an output of the log of convert – Marco Daniel Jun 05 '13 at 14:06
  • @MarcoDaniel If I add -debug All to convert on command line I can see a lot of information but conversion still works. If I the option to yaml file: - <arara> convert -debug All -delay @{delay} -loop @{loop} -density @{density} "@{getBasename(file)}.pdf" "@{getBasename(file)}.gif" > test.log 2>&1. Still nothing changes. The error is the same, process stops in same place and nothing is written in test.log. – Ignasi Jun 05 '13 at 16:26
  • I had a similar issue as I used the rule indent out of my editor. From the terminal everything works fine. I suppose you are compiling the document from the terminal with arara too. – Marco Daniel Jun 05 '13 at 16:35
  • 1
    @Ignasi: I suspect the "wrong" convert is being called (Windows has also a tool named convert, so there's a name clash). I have no Windows machine near me right now, so I cannot say for sure which PATH arara is assuming (either user or system, I suspect system). As a workaround, replace - <arara> convert in Chris' animate rule by the full path to ImageMagick's convert, say, - <arara> "C:\Program Files\ImageMagick\bin\convert.exe" (I don't know the exact path) and try running arara again. Please tell me if this works, otherwise we have to come up with another solution. :) – Paulo Cereda Jun 05 '13 at 17:26
  • @PauloCereda: You were right. With the full path, it worked. What I don't understand is why arara starts windows convert and command line starts ImageMagick convert. In any case, problem solved. If you think this question is not too localized and want to write an answer I'll accept it. – Ignasi Jun 05 '13 at 19:30
  • @Ignasi: I have a suspicion that the ImageMagick's path is set in your user variables settings, and arara relies solely on the system path. I'll investigate about it (I just need a Windows machine first), don't worry. :) I'll write an answer later on too. :) – Paulo Cereda Jun 05 '13 at 19:45
  • how about using the cmd c/, as in - <arara> @{ isWindows( "cmd /c convert", "convert" ) } -delay @{delay} -loop @{loop} -density @{density} "@{ getBasename(file) }.pdf" "@{ getBasename(file) }.gif" – cmhughes Jun 06 '13 at 02:02
  • @cmhughes: Your solution also works. If I've well understood this solution is equivalent to running convert from a command terminal and as I've ImageMagick's path in my user settings, ImageMagick's convert is the one which runs. Nice! – Ignasi Jun 06 '13 at 07:12
  • @Ignasi yes indeed- I'll test it myself later today and write an answer, I'll chat with Paulo later too :) – cmhughes Jun 06 '13 at 15:49

1 Answers1

7

arara version 4.0 answer

arara version 4.0 ships with animate.yaml, and Windows users might use the following, for example:

% arara: animate: {program: magick.exe}

old answer, out of date

The answer below is out of date

I apologize for not making my rule robust enough :)

As noted in the comments, the problem with my original answer is that Windows might not get the path correct. You can fix it by using

- <arara> @{ isWindows( "cmd /c convert", "convert" ) } -delay @{delay} -loop @{loop} -density @{density} "@{ getBasename(file) }.pdf" "@{ getBasename(file) }.gif"

Here's a complete, cross-platform, version

!config
# Make animated .gif file from .pdf
# author: Chris Hughes
# last edited by: cmh, June 6th 2013
# requires arara 3.0+
#
# Sample usage: 
#
# % arara: animate
# % arara: animate: {density: 200}
# % arara: animate: {density: 200, delay: 20}
#
# This rule is really just a shortcut for commands like the following
#
#  convert -delay 10 -loop 0 -density 300 myfile.pdf myfile.gif
#
# which will output myfile.gif
#
identifier: animate
name: animate
commands: 
- <arara> @{ isWindows( "cmd /c convert", "convert" ) } -delay @{delay} -loop @{loop} -density @{density} "@{ getBasename(file) }.pdf" "@{ getBasename(file) }.gif"
arguments:
- identifier: delay
  flag: <arara> @{parameters.delay}
  default: 10
- identifier: loop
  flag: <arara> @{parameters.loop}
  default: 0
- identifier: density
  flag: <arara> @{parameters.density}
  default: 300
cmhughes
  • 100,947
  • Oh a Windows user ;-) – Marco Daniel Jun 06 '13 at 17:29
  • Thank you for animate.yaml. Now it will be easier (at least for me) to submit animated gif's to TeX.SX. :-) – Ignasi Jun 07 '13 at 10:45
  • @Ignasi no problem, glad it helped :) isWindows is pretty darned useful :) – cmhughes Jun 07 '13 at 15:04
  • I'm using your animate.yaml with arara on Windows 10 and all works well except for the loop parameter: even if I set it to 1, I always get an infinite loop. It is not a problem of your rule because also the command convert -delay 10 -loop 1 -density 300 myfile.pdf myfile.gif has the same problem. Could you help me? I know this is not TEX.SE related, where should I ask it? – CarLaTeX Nov 05 '16 at 18:16
  • @CarLaTeX perhaps Stack overflow, such as http://stackoverflow.com/questions/tagged/imagemagick-convert (note the tags)....? – cmhughes Nov 05 '16 at 18:24
  • They've already answered me: http://stackoverflow.com/a/40442936/6689867. The problem was not the command but the program I used to open the .gif file! You always find a rapid solution on the StackExchange communities, you all are great! – CarLaTeX Nov 05 '16 at 21:07