yihui / animation

A gallery of animations in statistics and utilities to create animations
https://yihui.org/animation/
206 stars 59 forks source link

Extra quotes under OS X #71

Closed BillWeld closed 8 years ago

BillWeld commented 8 years ago

The gm command works fine in a shell with the quotes removed.

> gm.convert(files = file.path(image.dir, "*"), output = "lissajous.gif")
Executing: 
'gm convert' -loop 0 -delay 4.16666666666667 images/* 'lissajous.gif'
sh: gm convert: command not found
an error occurred in the conversion... see Notes in ?im.convert

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.1 (El Capitan)

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] animation_2.4

loaded via a namespace (and not attached):
[1] compiler_3.2.2 tools_3.2.2   
yulijia commented 8 years ago

Hi, I removed the extra quote in function gm.convert(). Could you please help us test if the new version of gm.convert() would generate GIF images successfully on your computer? The new function is tested under Fedora and Windows, it can generate animated GIF images successfully.

Here is the test script.


install.packages("devtools")
library(devtools)

dev_mode(on=T)

install_github("animation",username="yulijia ",ref="issue71")

library(animation)

## generate gif
owd = setwd(tempdir())
oopt = ani.options(interval = 0.05, nmax = 20)
png("bm%03d.png")
brownian.motion(pch = 21, cex = 5, col = "red", bg = "yellow",
                main = "Demonstration of Brownian Motion")
dev.off()
## use ImageMagick
im.convert("bm*.png", output = "bm-withoutQuotes1.gif")
## use GraphicsMagick
gm.convert("bm*.png", output = "bm-withoutQuotes2.gif")

# when finished do:
dev_mode(on=F)
BillWeld commented 8 years ago

It works! Or it works once I remove the extra space in “yulikia “ :)

Here’s what I was working on, which you are welcome to use as an example if you like:

Thanks! Rob

On Dec 5, 2015, at 3:34 AM, Lijia Yu notifications@github.com wrote:

Hi, I removed the extra quote in function gm.convert(). Could you please help us test if the new version of gm.convert() would generate GIF images successfully on your computer? The new function is tested under Fedora and Windows, it can generate animated GIF images successfully.

Here is the test script.

install.packages("devtools") library(devtools)

dev_mode(on=T)

install_github("animation",username="yulijia ",ref="issue71")

library(animation)

generate gif

owd = setwd(tempdir()) oopt = ani.options(interval = 0.05, nmax = 20) png("bm%03d.png") brownian.motion(pch = 21, cex = 5, col = "red", bg = "yellow", main = "Demonstration of Brownian Motion") dev.off()

use ImageMagick

im.convert("bm*.png", output = "bm-withoutQuotes1.gif")

use GraphicsMagick

gm.convert("bm*.png", output = "bm-withoutQuotes2.gif")

when finished do:

dev_mode(on=F) — Reply to this email directly or view it on GitHub https://github.com/yihui/animation/issues/71#issuecomment-162161323.

BillWeld commented 8 years ago

yulijia commented 8 years ago

Hi Rob, Beautiful Lissajous curve! If you would like provide an example of how to generate this figure, we're happy to help you add this example to animation package as a animation demo. Just fork this package, prepare and submit a pull request.

BTW, You can use the new gm.convert() via install the development version of this package.

Here is the code.

install.packages('animation', repos = 'http://yihui.name/xran')
BillWeld commented 8 years ago

Thanks. I’m afraid I don’t have the patience to learn everything I would need to know to integrate my code into an R package. Feel free to do it yourself though if you like. Here it is:

Rob

On Dec 5, 2015, at 9:27 PM, Lijia Yu notifications@github.com wrote:

Hi Rob, Beautiful Lissajous curve! If you would like provide an example of how to generate this figure, we're happy to help you add this example to animation package as a animation demo https://github.com/yihui/animation/tree/master/demo. Just fork this package, prepare and submit a pull request.

BTW, You can use the new gm.convert() via install the development version of this package.

Here is the code.

install.packages('animation', repos = 'http://yihui.name/xran') — Reply to this email directly or view it on GitHub https://github.com/yihui/animation/issues/71#issuecomment-162264419.

yihui commented 8 years ago

Github issues does not support attachments if you reply by email. You can either paste the code here, or send to us directly by email (xie <at> yihui.name or yulj2010 <at> gmail.com). Thanks!

BillWeld commented 8 years ago

On Dec 7, 2015, at 11:30 PM, Yihui Xie notifications@github.com wrote:

Github issues does not support attachments if you reply by email. You can either paste the code here, or send to us directly by email (xie yihui.name or yulj2010 gmail.com). Thanks!

— Reply to this email directly or view it on GitHub https://github.com/yihui/animation/issues/71#issuecomment-162759780.

lissajous.R

Rob Steele

2013-11-09

2015-12-05 Bug fixes.

2015-12-07 Adapted as animation package demo.

Animate a series of lissajous.

library(animation)

plot.lissajous <- function(omega.x, omega.y, delta = 0, num.thetas = 200, ...) { thetas <- seq(from = 0, to = 2 * pi, length.out = num.thetas) xs <- sin(omega.x * thetas + delta) ys <- cos(omega.y * thetas) plot(x = xs, y = ys, type = "l", ann = FALSE, axes = FALSE, ...) }

create.lissajous.gif <- function(gif.name = "lissajous.gif", frames.per.second = 24, loop.length = 3, ## in seconds max.degree = 5, line.width = 3, image.dir = tempdir()) {

Create animation frames.

num.frames <- round(loop.length \* frames.per.second)
deltas <- head(seq(from = 0, to = 2 \* pi, length.out = num.frames + 1), -1)
image.files <-
    sapply(X = seq_len(num.frames), FUN = function(i) {
        image.file <- file.path(image.dir, sprintf("img-%04d.png", i))
        png(file = image.file)
        par(mar   = c(1, 1, 1, 1),
            mfcol = c(max.degree, max.degree))
        for (omega.x in seq_len(max.degree)) {
            for (omega.y in seq_len(max.degree)) {
                plot.lissajous(omega.x = omega.x, omega.y = omega.y, delta = deltas[i], lwd = line.width)
            }
        }
        dev.off()
        return(image.file)
    })

## Combine the individual image files into an animated GIF file.
oopt <- ani.options(interval   = 1 / frames.per.second,
                    loop       = TRUE,
                    autobrowse = FALSE)

gm.convert(files = file.path(image.dir, "*"), output = gif.name)

## Restore animation options.
ani.options(oopt)

}

create.lissajous.gif()