{"id":554,"date":"2014-04-01T12:22:51","date_gmt":"2014-04-01T12:22:51","guid":{"rendered":"http:\/\/daniepstein.com\/daniepstein\/?p=554"},"modified":"2014-06-26T08:25:26","modified_gmt":"2014-06-26T08:25:26","slug":"mogrify-more-pleasant-than-it-sounds","status":"publish","type":"post","link":"https:\/\/daniepstein.com\/daniepstein\/mogrify-more-pleasant-than-it-sounds\/","title":{"rendered":"Mogrify &#8211; more pleasant than it sounds"},"content":{"rendered":"<p>If you are lucky or smart enough to use Ubuntu, then you have a wealth of tools sitting just under your keyboard that you might\u00a0know owt about.<\/p>\n<p>Two of those are the convert and mogrify tools, which come from the <a title=\"Image Magick\" href=\"http:\/\/www.imagemagick.org\/\">Imagemagick<\/a> stable. I use these quite frequently for batch conversion jobs.<\/p>\n<p>Here is an example of what these tools can do, specifically <strong>mogrify<\/strong> which acts on batches of files.<\/p>\n<p>I have a folder load of transparent images that the client wants on a white background, so I open the command line, navigate to that folder (or just open the command line in that folder directly using Nemo instead of Nautilus) and type the following incantation:<\/p>\n<p><span style=\"color: #3366ff;\"><strong>mogrify -format jpg -quality 100 -fill white -opaque none *.png<\/strong><\/span><\/p>\n<p>If we break this down into individual components, then<\/p>\n<p><strong><span style=\"color: #3366ff;\">mogrify<\/span><\/strong> this is the command itself<\/p>\n<p><span style=\"color: #3366ff;\"><strong>-format jpg <\/strong><\/span>The output format, in this case jpg<\/p>\n<p><span style=\"color: #3366ff;\"><strong>-quality 100 <\/strong><\/span>for jpgs specifies the compression or quality levels. 100 is tops, 1 is rubbish.<\/p>\n<p><span style=\"color: #3366ff;\"><strong>-fill white<\/strong><\/span> the colour of the fill which will be determined by the next command.<\/p>\n<p><strong><span style=\"color: #3366ff;\">-opaque none<\/span><\/strong> deals with the alpha (transparency) channel, by filling it with a colour, which has handily just been specified.<\/p>\n<p><span style=\"color: #3366ff;\"><strong>*.png<\/strong><\/span> simply tells mogrify to grab any file that ends in &#8220;.png&#8221;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are lucky or smart enough to use Ubuntu, then you have a wealth of tools sitting just under your keyboard that you might\u00a0know owt about. Two of those are the convert and mogrify tools, which come from the &hellip; <a href=\"https:\/\/daniepstein.com\/daniepstein\/mogrify-more-pleasant-than-it-sounds\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":""},"categories":[3],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2UnW3-8W","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/daniepstein.com\/daniepstein\/wp-json\/wp\/v2\/posts\/554"}],"collection":[{"href":"https:\/\/daniepstein.com\/daniepstein\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daniepstein.com\/daniepstein\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daniepstein.com\/daniepstein\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daniepstein.com\/daniepstein\/wp-json\/wp\/v2\/comments?post=554"}],"version-history":[{"count":5,"href":"https:\/\/daniepstein.com\/daniepstein\/wp-json\/wp\/v2\/posts\/554\/revisions"}],"predecessor-version":[{"id":559,"href":"https:\/\/daniepstein.com\/daniepstein\/wp-json\/wp\/v2\/posts\/554\/revisions\/559"}],"wp:attachment":[{"href":"https:\/\/daniepstein.com\/daniepstein\/wp-json\/wp\/v2\/media?parent=554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daniepstein.com\/daniepstein\/wp-json\/wp\/v2\/categories?post=554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daniepstein.com\/daniepstein\/wp-json\/wp\/v2\/tags?post=554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}