## Using the slickR package, which wraps a javascript carousel library slick
Birdland, the movie
On my phone, I picked “save as movie” from the “dot-dot-dot”menu.
First, I edited the endpoints, the “In” and the “Out”, moving them in to make a shorter movie.
Before that, I duplicated the live photo as a live photo, in case I messed up. (I didn’t mess up)
Before that, I took a photo of a hummingbird that seemed to catch it just after it disappeared. Oops! That’s the funny thing about birds and bees photography, though. A lot of times you get the photo when you don’t think you did.
What I did next
Next I made two folders on my computer: one, a publish folder called “YoungHummingbird” in the posts folder of this Quatro blog, and the other, a working folder called “movieHummingbirdRest”, in my ‘repos’ folder. Within ‘movieHumingbirdRest’ I made a subfolder called ‘moviesHere’ (previously known as ‘idata’).
iPhoto stores photos in a format called ‘HEIC’. Instead of using that directly (my installed version of imagemagick did not seem to read it), I exported to a quicktime movie (.mov) file, using “Save as movie” on the phone’s photos app. I could not find this menu option on the MacOS version of the Photos app, so I went back to the phone to do it.
Then, I put the movie into ‘moviesHere’. Easy to remember next time!!
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)
#install.packages("av")
library(av)
library(magick)
library(here)
bird3 <- magick::image_read_video("movieHere/MovieHummingbirdRestCrop.mov", fps=NULL)
#https://www.r-bloggers.com/2020/08/basic-manipulation-of-gif-frames-with-magick/
#bird3 <- magick::image_read("idata/IMG_8948.heic")
outframe <- length(bird3)
## Interactively look at the bird frames
bird3[1]
bird3[16]
bird3[17]
bird3[18]
bird3[19]
bird3[29]
bird3[28]
bird3[outframe]
#. Ooops! Bird is on its side!!
# for(i in 1: length(bird3)) {
# zeropadnum <- sprintf("%03i",i)
# eachname = paste0("crowhawk",zeropadnum,".jpg")
# magick::image_write(bird3[i],path=eachname)
# }
holderfolder <- "frames/"
dir.create(here(holderfolder)) ## make the frames folder
## skip the 1st boring frame
for(i in 2: length(bird3)) {
zeropadnum <- sprintf("%03i",i)
eachname = paste0("birdfly",zeropadnum,".jpg")
### HEY! bird is NOT on its side:
if(FALSE) {
frame = magick::image_rotate(bird3[i],90)
} else {
frame = bird3[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.
Again!
Then, with everything in hand, I noticed a lot of empty space around the bird. Sky above, trees below. You would barely be able to see the little bird!
So on MacOS, I opened the .mov file with Pixelmator, and cropped it to a 16:9 aspect ratio, just for the sake of old times, and it is as you see it.
‘Old times’ being 1986, when I saw prototypes for every piece of HDTV equipment on display at the National Association of Broadcasters (NAB) meetings in Atlanta. That was the aspect ratio of the new screens, replacing the 4:3 standard to the televisions of the time. HDTV? That bird has flown!
I re-ran the script, copied the jpeg files over to the publish directory, and got rid of about ten frames between the bird fluffing at the start, and leaping off the branch to the right.
Code
## Click button at right or left to advance by frame:library(slickR) bird_frame_filenames <-list.files("frames/", 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
Summary:
Take a live photo of a bird
transfer it to 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
---title: "Wings Forward"author: "George Girton"date: "2023-07-11"categories: [Rstats, Animation]image: "flyfordward.png"draft: false---# Wings forward![Hummingbird on the move](flyfordward.png)## Click button at right or left to advance by frame:```{r}library(slickR) bird_frame_filenames <-list.files("frames/", pattern=".jpg", full.names =TRUE)slickR(bird_frame_filenames, height =250, width='80%') +settings(dots =TRUE,infinite=TRUE,speed =0,fade =TRUE,cssEase ='linear')## Using the slickR package, which wraps a javascript carousel library slick```### Birdland, the movieOn my phone, I picked "save as movie" from the "dot-dot-dot"menu.- First, I edited the endpoints, the "In" and the "Out", moving them in to make a shorter movie.<!-- -->- Before that, I duplicated the live photo as a live photo, in case I messed up. (I didn't mess up)- Before that, I took a photo of a hummingbird that seemed to catch it just after it disappeared. Oops! That's the funny thing about birds and bees photography, though. A lot of times you get the photo when you don't think you did.### What I did nextNext I made two folders on my computer: one, a publish folder called "YoungHummingbird" in the posts folder of this Quatro blog, and the other, a working folder called "movieHummingbirdRest", in my 'repos' folder. Within 'movieHumingbirdRest' I made a subfolder called 'moviesHere' (previously known as 'idata').iPhoto stores photos in a format called 'HEIC'. Instead of using that directly (my installed version of imagemagick did not seem to read it), I exported to a quicktime movie (.mov) file, using "Save as movie" on the phone's photos app. I could not find this menu option on the MacOS version of the Photos app, so I went back to the phone to do it.Then, I put the movie into 'moviesHere'. Easy to remember next time!!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 oneIn a prior rendition of this, I had to rotate the imageframe = magick::image_rotate(bird2\[i\],90)but THIS time, no such problem!```` ``` {{r}}library(magick)#install.packages("av")library(av)library(magick)library(here)bird3 <- magick::image_read_video("movieHere/MovieHummingbirdRestCrop.mov", fps=NULL)#https://www.r-bloggers.com/2020/08/basic-manipulation-of-gif-frames-with-magick/#bird3 <- magick::image_read("idata/IMG_8948.heic")outframe <- length(bird3)## Interactively look at the bird framesbird3[1]bird3[16]bird3[17]bird3[18]bird3[19]bird3[29]bird3[28]bird3[outframe]#. Ooops! Bird is on its side!!# for(i in 1: length(bird3)) {# zeropadnum <- sprintf("%03i",i)# eachname = paste0("crowhawk",zeropadnum,".jpg")# magick::image_write(bird3[i],path=eachname)# }holderfolder <- "frames/"dir.create(here(holderfolder)) ## make the frames folder## skip the 1st boring framefor(i in 2: length(bird3)) { zeropadnum <- sprintf("%03i",i) eachname = paste0("birdfly",zeropadnum,".jpg") ### HEY! bird is NOT on its side: if(FALSE) { frame = magick::image_rotate(bird3[i],90) } else { frame = bird3[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.## Again!Then, with everything in hand, I noticed a lot of empty space around the bird. Sky above, trees below. You would barely be able to see the little bird!So on MacOS, I opened the .mov file with Pixelmator, and cropped it to a 16:9 aspect ratio, just for the sake of old times, and it is as you see it.::: callout'Old times' being 1986, when I saw prototypes for every piece of HDTV equipment on display at the National Association of Broadcasters (NAB) meetings in Atlanta. That was the aspect ratio of the new screens, replacing the 4:3 standard to the televisions of the time. HDTV? That bird has flown!:::I re-ran the script, copied the jpeg files over to the publish directory, and got rid of about ten frames between the bird fluffing at the start, and leaping off the branch to the right.```{r}## Click button at right or left to advance by frame:library(slickR) bird_frame_filenames <-list.files("frames/", pattern=".jpg", full.names =TRUE)slickR(bird_frame_filenames, height =250, width='80%') +settings(dots =TRUE,infinite=TRUE,speed =0,fade =TRUE,cssEase ='linear')## Using the slickR package, which wraps a javascript carousel library slick ```Summary:- Take a live photo of a bird- transfer it to 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!