Rstats
Animation
Bird photo
Author

George Girton

Published

December 19, 2024

Winter Solstice

Red-tailed hawk flies off to another tree

Hawk leaps into the air

Click button at right or left to advance by frame:

Code
library(slickR)

    bird_frame_filenames <- list.files("hawkframes/", pattern=".jpg", full.names = TRUE)

slickR(bird_frame_filenames, height = 250, width='80%') +
  settings(dots = TRUE,
  infinite= TRUE,
  speed = 0,
  fade = TRUE,
  cssEase = 'linear')
Code
## Using the slickR package, which wraps a javascript carousel library slick

Tree Hawk, the Christmas movie

  • I saw this hawk in a tree, and went outside to get a photo of it. I’ve seen it there before (I would be the first to admit that it could be a different hawk). Just as I was getting the photo, it started to fly to another tree
  • I picked “save as movie” from the “dot-dot-dot”menu in the photos app on my iPhone.
  • In the new movie I edited the endpoints( the “In” and the “Out”) moving them in to make a shorter movie.

I put the movie into a working folder called ‘moviesHere’ in “movieHummingbirdRest”, in my ‘repos’ folder.

At this point it was in a quicktime movie (.mov) file, using “Save as movie” on the phone’s photos app.

Here’s the code below for exporting the frames. (I ran it interactively in R Studio, it isn’t part of this live Quarto page.

To be aware of: without the “fps=NULL”, it just gives you one (1) frame. But you want thirty or so. Add the parameter, and length of bird3 image array shows 30 frames instead of one

In a prior rendition of this, I had to rotate the image

frame = magick::image_rotate(bird2[i],90)

but THIS time, no such problem!

``` {{r}}

library(magick)
library(here)

hawk <- magick::image_read_video("movieHere/TreeHawk.mov", fps=NULL)

outframe <- length(hawk)

## Interactively look at the bird frames

hawk[1]
hawk[16]
hawk[17]
hawk[18]
hawk[19]
hawk[29]
hawk[28]
hawk[outframe]




holderfolder <- "hawkframes/"

dir.create(here(holderfolder))  ## make the frames folder

## 1st frame was not boring
for(i in 1: length(hawk)) {
  zeropadnum <- sprintf("%03i",i)
  eachname = paste0("hawkfly",zeropadnum,".jpg")
  ### HEY!  bird is NOT on its side:
  if(FALSE) {  frame = magick::image_rotate(bird3[i],90)
  } else {
    frame = hawk[i]
  }
  magick::image_write(frame,path=paste0(holderfolder,eachname))
}



```

Because the writable folder “frames” must pre-exist, and the image_write() function does not create it, I added a prior call to dir.create(), which does not over-write if the folder already exists. I added the ‘here’ package to the project in order to make this nice. magick’s image_write() is already here-relative.

Summary:

  • Take a ‘live photo’ of a bird (it doesn’t have to be a big hawk)

  • save it as a video

  • think up good folder names for your repo and your post

  • process it to frames

  • Re-do it

  • Clip a still photo out of there and put it in your publish folder

  • Do it again!

Red-tailed hawk flying, treetops and clouds in the background

Hawk on way to new tree

— all photos Copyright © 2022-2024 George D Girton all rights reserved