### ImageMagick and FFMPEG commands Remember that the order of parameters/options is very important. ##### convert images and save to another dir convert *.png -set filename:original %t 'export/%[filename:original].jpg' ##### resize, change dpi and quality convert *.jpg -resize 1600 -quality 70% -depth 72 -units pixelsperinch resized.jpg convert *.jpg -set filename:original %t -resize 1600 -quality 70% -depth 72 -units pixelsperinch 'resized_%[filename:original].jpg' ##### resize and crop convert *.jpg -resize "460x460^" -gravity center -crop 460x460+0+0 +repage crop.jpg mogrify -path ../voxels3 -format png -resize "512x512^" -gravity center -crop 512x512+0+0 +repage *.png ##### resize to fit with background convert *.png -background black -resize 1024x768 -gravity center -extent 1024x768 fit.png ##### mosaic with cropped images montage crop*.jpg -geometry 460x460+0+0 mosaic.jpg ##### scale and stack images convert *.png -append -scale 50% stacked.png ##### animated gif from png files convert -delay 5 -loop 0 *.png ../animation.gif ##### from mov to gif (with ffmpeg) thanks to ###### 1. convert video to PNG sequence with FFMPEG ffmpeg -i video.mov -r 10 -s 640x400 -f image2 frames/frame-%03d.png * `-i video.mov` the video file * `-r 10` the rate * `-s 640x400` the output size * `-f image2` the output format, a series of still images * `frames/frame-%03d.png` is a printf format string specifying the output filenames, in this case `dir/name-###.png`, a series of PNG images called 001.png, 002.png, 003.png, and so on. ###### 2. convert PNG sequence to animated GIF convert frames/*.png -delay 1x8 -coalesce -layers OptimizeTransparency animation.gif * `frames/*.png` input files * `-delay 1x8` says that the animation should play a frame every 1/8 of a second. I computed this number by looking at the frame rate of the original video (24) and dividing by the number of frames each drawing plays for (3). Note that most browsers slow down animations that play faster than 20 frames per second, or 1/50 second per frame. Most videos play back at between 25 and 30 fps, so you may have to drop every other frame or so if you care about accuracy of playback speed. * `-coalesce` apparently “fully define[s] the look of each frame of an [sic] GIF animation sequence, to form a ‘film strip’ animation,” according to the documentation. * `-layers OptimizeTransparency` tells ImageMagick to replace portions of each frame that are identical to the corresponding parts of the preceding frame with transparency, saving on file size. * `animation.gif` output file ##### convert gif to images and video convert ani.gif -coalesce ani.png ffmpeg -f image2 -i ani-%d.png ani.mpg -vb 20M ##### prores ffmpeg -i aya-mpeg4.mov -c:v prores -profile:v 2 aya-prores.mov ffmpeg -i aya-mpeg4.mov -vcodec prores_ks -pix_fmt yuva444p10le -alpha_bits 16 -profile:v 4444 -f mov aya-prores-alpha.mov ##### stretch video ffmpeg -i input.mp4 -filter_complex "setpts=PTS/10" output.mp4 ##### video from png ffmpeg -r 8 -i stylegan-%06d.png -c:v libx264 -vf fps=30 -pix_fmt yuv420p latent-space-walker.mp4