Thursday, August 25, 2022

ImageMagick bash command - animated GIF <=> JPG/PNG

Accidentally or intentionally converted animated GIF to a bunch of JPGs or PNGs, by:

$ convert  anime.gif  anime.jpg

# above command output a bunch of files:

anime-0.jpg anime-12.jpg anime-16.jpg anime-2.jpg anime-23.jpg anime-5.jpg anime-9.jpg

anime-1.jpg anime-13.jpg anime-17.jpg anime-20.jpg anime-24.jpg anime-6.jpg anime.gif

anime-10.jpg anime-14.jpg anime-18.jpg anime-21.jpg anime-3.jpg anime-7.jpg

anime-11.jpg anime-15.jpg anime-19.jpg anime-22.jpg anime-4.jpg anime-8.jpg

# Note that files are sorted as 0, 1, 10, 11, 12, ... 19, 2, 20, 21, ...

# so, to convert it back, it is NOT as easy as

convert  *.jpg  out.gif

# above gave jerky animation due to wrong sequence of images

# we need:

convert `ls *.jpg | sort --version-sort` out.gif 

# as expected, version sort gives 1, 2, 3, ... 10, 11, 12, ... 19, 20, 21, ...  

# more control, for example:

convert -delay 10 -loop 0 `ls *.jpg | sort --version-sort` out10.gif

delay is 10 * 10ms     ie.  1/10 sec per frame

loop 0 meaning no repeat



Labels: , , ,

Tuesday, May 15, 2018

playing Docker on ubuntu 18.04 LTS

# update package list:
$ sudo apt update

# installation:
$ sudo apt install docker

# by now, docker is sudo only.  if want to skip that 'sudo'
$ sudo groupadd docker
$ sudo useradd -aG docker $USER
doc said logout and re-login... i found it requires restarting.

# test environment, run helloworld
$ docker run hello-world
# will pull first if image not yet existed.



##  examples


# try node.js
$ docker pull node   # see online slim version
...
$ docker run node   # run and end and return
$ docker run -td node  # run in a new (t)ty, and (d)etached, end and return
$ docker run -it node   # run in a new (t)ty, (i)nteractively - prompt node's '>', ctrl-d to exit

# list downloaded images
$ docker images

# docker --help


Labels: , , , , , , ,