ImageMagick
Procrasticoding: annotate animated GIFs (or even add a picture/watermark)
The sun rose, the cats were watching the birds on the windowsill and at first I just wanted to take a cute picture of them sitting soo close, but then I had another inspiration ..
0. Prepared the logo from some internetsearch; stripped of colors, converted to 3-color-GIF with transparency: all done by GIMP and some magic.
1. converted the video to GIF with greyscaling and resizing
2. merged the two pictures while optimizing the layers and applying some contrast
1 2 3 |
ffmpeg -i VID_20160420_061216.mp4 -vf scale=320:180 -strict -2 -vf format=gray video_gray.mp4 && \ ffmpeg -i video_gray.mp4 -t 3 -b:v 1024k -vf scale="320x180" gray320.gif && \ convert gray320.gif -contrast -coalesce -gravity SouthWest -draw 'image Over 0,0 0,0 "leben2.gif"' -layers Optimize combined320.gif |
BTW: sometimes empty phrase-error messages spark my fury … “convert.im6: non-conforming drawing primitive definition `image’ @ error/draw.c/DrawImage/3158.
” … and what does this tell me now?!?
But at least I am not the first one who understood nothing! Thank you.
Video to *good* GIF
You can use a crappy app or some webservice … or DIY!
1 |
$ ffmpeg -t 3 -ss 00:00:04 -i INPUTVIDEO.mp4 -b:v 2048k -vf scale="500x281" OUTPUT.gif |
read: start at second 4 with length 3, use high quality-conversion, downscale (because scaling with ‘convert’ will result in artifacts because of the color-indexing), out-filename
If some rotation is needed (-vf “transpose=2” is also an option, but the quality suffered), add it afterwards via convert.
1 |
$ convert -rotate 270 OUTPUT.gif OUTPUT_rot.gif |
OSX: How to get imageMagick (working with fonts)?
Hmm, OSX offers out of the box a lot of UI-programs, but is missing most of the *NIX-fun. So if you need imageMagick for your work, you are missing it. The prepared installers are missing the support for the font-manipulation.
Of course, you can download and build all packages by yourself from scratch … or you use one of the nice packet-managers like fink, macports or homebrew.
The fastest way to get a usable OSX (tried with 10.10 and 10.8) for the contactSheet-script is by executing those simple four commands in your terminal. Existing internet-connection assumed:
1 2 3 4 |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew install fontconfig brew install imagemagick brew install ghostscript |
(Linux: use your favorite package-manager.
Windows: :DDDDD I guess it won’t work until you also get some bash-replacement.)
Check afterwards the current configuration. The list of delegates should show “freetype” or “fontconfig”. If both are missing, then rendering the filename onto the thumbnails won’t work!
1 2 |
$ convert -list configure | grep DELEGATES DELEGATES bzlib mpeg freetype jng jpeg lzma png tiff xml zlib |
createContactSheet 0.4
Okee, sorry for the continued spam about this small bash-project, but I am a little bit excited. It turned out much more powerful than expected. I learned a lot new and really useful stuff. I am also really confident now about the future of “bash & me” 😉
I improved the latest state with an idea a good friend pointed out: why don’t you add the original file name to each thumbnail? For a better overview? This is done also by imageMagick (convert); also append now the base-directory as footer-note. Because for my workflow the dir-name is the scan-date and the emulsion-type.
Some other improvements are: changed workflow (negative-conversion on each picture instead of the whole combined one; therefore no “filling of the last row” needed); script-parameters for help and version and for suppressing the negfix8-conversion; cleaner code.
I have also some more ideas in mind, but I think for now it is enough. It was fun, but I also want to discover some other areas of IT!
Download this: createContactSheet_0.4
createContactSheet 0.3
I fixed a small glitch, which was included in the first releases: input-filenames with spaces were not treated correctly therefore no result was created. Fixed by some string-replacement and setting the IFS-variable which dictates that bash should treat spaces not as separators.
For the next release some filename-embedding into the thumbnail is planned. But this has to happen after the negfix8-conversion else it would alter the conversion itself ..
Download this: version_0.3
Small hint: git offers a really nice exporting-function which will just include the current state of the given branch:
1 |
git archive master --output="version_0.3.zip" |
You want a contact sheet with that?
Slogan is like always: “If you are not ashamed of the first release of XYZ, then you waited too long or have no self-reflection.”
It would be nice to have a preview shaped like the original contact sheets of a HDR-film scan. So you could screenshot the thumbnails and print this.
Or you try the following script:
- it takes all TIF from one directory (assuming they are HDR-scans from SilverFast)
- creates thumbnails with a longer side of 400px into a separate directory
- appends six thumbnails for each row and the combines all rows to a single picture. If the number of pictures does not fit, the last picture is repeatedly appended (this is necessary due to the negative conversion)
- ‘negfixes’ them (negative conversion done by the great original script of negfix8 from JaZ99!)
- spreads the contrast in two diffent approaches (check yourself which is your most liked version)
As a result you get something like this:
As you can see: the black strips at the left and right side of the pictures still exist. But since I scan always the HDR-files with top and bottom cropped, the black borders don’t show up there. Time to change my workflow?
Download:
- newest version: contactSheet_0.2
- contactSheet_0.1
HowTo:
- download & extract the two scripts
- open a bash-terminal an navigate INTO the directory with the HDR-scans
- run “/PATHTOSCRIPT/createContactSheet.sh” and wait for 2 to 3 minutes
Future plans:
- improve the structure of the code and add some more comments and make it less error-prone
- full clean-up after the creation (by default; suppresable by param)
- suppress the negfixing by param so also E6 (slide)-scans can be ‘contact sheeted’
- make the script use the general temp-folder and put just the final two contact sheets into the target folder (so the data stays clean)
- add the filename in the bottom-right as transparent overlay so you know which thumbnail belongs to which picture
edit 20150603: Just uploaded version 0.2 which improves performance a lot and cleans everything up and has a nicer structure!
Combine several images to a GIF-animation
- convert all JPG from the current directory to a looping GIF with 0.2 s delay and resize them to 600 px for the width:
1 |
convert -loop 0 -delay 20 -resize 600 img*.jpg out600.gif |
- GIF-animation was never easier! This is the result from combining 36 E6-photos (taken with a delay of roundabout 1 s).
Stitch two pictures together
* install imagemagick
1 |
$ convert <file0> <file1> +append <outfilename> |
* note: + appends horizontally; – vertically