{"id":2104,"date":"2016-07-15T16:13:46","date_gmt":"2016-07-15T15:13:46","guid":{"rendered":"http:\/\/johnjohnston.info\/106\/?p=2104"},"modified":"2016-07-15T16:18:20","modified_gmt":"2016-07-15T15:18:20","slug":"commandline-gifs-cartoon-the-nitty-gritty","status":"publish","type":"post","link":"https:\/\/johnjohnston.info\/106\/commandline-gifs-cartoon-the-nitty-gritty\/","title":{"rendered":"Commandline gifs: Cartoon The Nitty Gritty"},"content":{"rendered":"<p>I&#8217;ve covered most of this before, but given <a href=\"http:\/\/bavatuesdays.com\/gimme-the-bat\/\">the news<\/a> that <a href=\"http:\/\/bavatuesdays.com\/dannys-wheels\/\">someone reads this stuff<\/a>, I though I&#8217;d document it a bit more.<\/p>\n<p>Prerequisites: ffmpeg, imagemagick, gifsicle, I&#8217;ve installed all of these commandline apps via <a href=\"http:\/\/brew.sh\/\">Homebrew. <\/a><\/p>\n<p>Cartoon <a href=\"http:\/\/www.fmwconcepts.com\/imagemagick\/cartoon\/index.php\">Fred&#8217;s ImageMagick Scripts: CARTOON<\/a>.<\/p>\n<p>I downloaded this then made it executable using the terminal:<\/p>\n<p><code>chmode +x cartoon<\/code><\/p>\n<p>I then moved in into \/usr\/local\/bin\/<\/p>\n<p>the proper way is probably<br \/>\n<code>mv cartoon \/usr\/local\/bin\/<\/code><\/p>\n<p>but I did <code>open \/usr\/local\/bin\/<\/code> which open the folder in the finder and dragged the file across.<\/p>\n<p>I ned a movie so:<\/p>\n<div class=\"jetpack-video-wrapper\"><iframe loading=\"lazy\" title=\"Best 60s Dancer Boy Ever - The Nitty Gritty\" width=\"840\" height=\"630\" src=\"https:\/\/www.youtube.com\/embed\/8S3Yt-NxY0E?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/div>\n<p>Which I downloaded with <a href=\"http:\/\/fastesttube.kwizzu.com\/\">YouTube downloader tool &#8211; Fastesttube!<\/a>.<\/p>\n<p>I copied the download into a folder and renamed it dancer.mp4<\/p>\n<p>In the terminal I move into the folder by typing <em>cd <\/em> and dragging the folder int the window and pressing return.<\/p>\n<p>I then made a new folder <code>mkdir jpg2<\/code><\/p>\n<p>I switched to the finder and previewed the movie to find out where I want to start extracting frames, which turns out to be at 26 seconds, and I want to get 3 seconds worth at 6 frames per second:<\/p>\n<p><code>ffmpeg -ss 00:00:26.000 -i dance.mp4 -t 00:00:03.000 -r 6 jpg2\/dance_%04d.jpg<\/code><\/p>\n<p>This give me 18 jpgs in a folder.<\/p>\n<p>I move int othat folder and make a new one:<br \/>\n<code>cd jpg2<\/code><br \/>\n<code>mkdir toon<\/code><\/p>\n<p>I then use cartoon to make a cartoon image for each jpg in the toon folder:<\/p>\n<p><code>for i in *.jpg; do cartoon $i toon\/$i;done<\/code><br \/>\n(cartoon uses imagemagick)<\/p>\n<p>This takes a wee while, I then make yet another folder:<\/p>\n<p><code>mkdir gifs<\/code><\/p>\n<p>and convert all the cartoon jpgs into gifs:<\/p>\n<p><code>for i in *.jpg; do convert $i gifs\/$i.gif;done<\/code><\/p>\n<p>(convert is part of imagemagick)<\/p>\n<p>Finally I make a gif<\/p>\n<p><code>gifsicle --delay 12 gifs\/*.gif --loopcount -O3 --colors 16 -o ..\/..\/dance.gif<\/code><\/p>\n<p>You can see the gif ends up in the top folder. There is a 12\/100 of a second delay, it loops forever, is reduced to 16 colors\u00a0and optimised (O3).<\/p>\n<p><a href=\"http:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2016\/07\/Screen-Shot-2016-07-15-at-15.58.07.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2107\" src=\"https:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2016\/07\/Screen-Shot-2016-07-15-at-15.58.07.png\" alt=\"Screen Shot 2016-07-15 at 15.58.07\" width=\"810\" height=\"377\" srcset=\"https:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2016\/07\/Screen-Shot-2016-07-15-at-15.58.07.png 810w, https:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2016\/07\/Screen-Shot-2016-07-15-at-15.58.07-300x140.png 300w, https:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2016\/07\/Screen-Shot-2016-07-15-at-15.58.07-768x357.png 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Along the way there are <strong>a lot<\/strong> of other possibilities, convert for example can adjust the brightness and contrast (and a raft of other things). I brightened these\u00a0ones up a bit:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2109\" src=\"https:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2016\/07\/gunstick.gif\" alt=\"gunstick\" width=\"500\" height=\"209\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2108\" src=\"https:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2016\/07\/stickgun2.gif\" alt=\"stickgun2\" width=\"500\" height=\"281\" \/><\/p>\n<p>In reaction to<\/p>\n<blockquote class=\"twitter-tweet\" data-width=\"550\">\n<p lang=\"en\" dir=\"ltr\">New blog post: &quot;Gimme the Bat&quot; <a href=\"https:\/\/t.co\/DYU4Exj7Wl\">https:\/\/t.co\/DYU4Exj7Wl<\/a> I&#39;M COMING FOR YOU <a href=\"https:\/\/twitter.com\/johnjohnston\">@johnjohnston<\/a><\/p>\n<p>&mdash; Jim Groom (@jimgroom) <a href=\"https:\/\/twitter.com\/jimgroom\/status\/753731986561306625\">July 14, 2016<\/a><\/p><\/blockquote>\n<p><script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p>Like the\u00a0cartooning\u00a0of videos a <a href=\"http:\/\/johnjohnston.info\/106\/this-aint-no-rotoscope\/\">couple of posts ago<\/a>\u00a0there is the opportunity to see and understand a bit more about film using this technique. Jim might be thinking that (<a href=\"http:\/\/bavatuesdays.com\/dannys-wheels\/#comment-238087\">says Alan<\/a>) but so far I am just having fun.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve covered most of this before, but given the news that someone reads this stuff, I though I&#8217;d document it a bit more. Prerequisites: ffmpeg, imagemagick, gifsicle, I&#8217;ve installed all of these commandline apps via Homebrew. Cartoon Fred&#8217;s ImageMagick Scripts: CARTOON. I downloaded this then made it executable using the terminal: chmode +x cartoon I &hellip; <a href=\"https:\/\/johnjohnston.info\/106\/commandline-gifs-cartoon-the-nitty-gritty\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Commandline gifs: Cartoon The Nitty Gritty&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":2105,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[74,113],"tags":[180,179,207,181,172],"class_list":["post-2104","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-animatedgif","category-tutorial","tag-comandline","tag-ffmpeg","tag-gifsicle","tag-imagemagick","tag-jim-groom"],"better_featured_image":{"id":2105,"alt_text":"","caption":"","description":"","media_type":"image","media_details":{"width":490,"height":360,"file":"2016\/07\/dance.gif","sizes":{"thumbnail":{"file":"dance-150x150.gif","width":150,"height":150,"mime-type":"image\/gif","source_url":"https:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2016\/07\/dance-150x150.gif"},"medium":{"file":"dance-300x220.gif","width":300,"height":220,"mime-type":"image\/gif","source_url":"https:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2016\/07\/dance-300x220.gif"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":2104,"source_url":"https:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2016\/07\/dance.gif"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2016\/07\/dance.gif","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3RLlC-xW","_links":{"self":[{"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/posts\/2104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/comments?post=2104"}],"version-history":[{"count":4,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/posts\/2104\/revisions"}],"predecessor-version":[{"id":2112,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/posts\/2104\/revisions\/2112"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/media\/2105"}],"wp:attachment":[{"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/media?parent=2104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/categories?post=2104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/tags?post=2104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}