{"id":191,"date":"2010-01-08T17:52:27","date_gmt":"2010-01-08T22:52:27","guid":{"rendered":"http:\/\/nylinuxhelp.com\/blogs\/?p=191"},"modified":"2010-01-08T17:52:27","modified_gmt":"2010-01-08T22:52:27","slug":"save-time-on-tasks","status":"publish","type":"post","link":"https:\/\/nylinuxhelp.com\/blogs\/command-line\/save-time-on-tasks","title":{"rendered":"Save time on tasks"},"content":{"rendered":"<h2>Learning basic Linux commands helps save you time when working on repetitive tasks.<\/h2>\n<p>Imagine you had a folder of images in *.bmp format.\u00a0 File sizes of bmps are larger than jpg files because they contain more information.\u00a0 To convert these bmp files to jpgs you could open a .bmp file in a graphics program (such as photoshop), select processes (such as &#8216;save for web&#8217;), set the format to convert to, and finally, save the file &#8220;as&#8221; <strong>filename.jpg<\/strong>.\u00a0 Converting each image takes about five to six &#8220;manual&#8221; steps, depending on how you opened the source files and where you save the destination files.\u00a0 If you had a folder with 100 images, it becomes tedious repetition.\u00a0 <strong>There are better ways to do this<\/strong>.<\/p>\n<p>You could create a batch process or &#8220;macro&#8221; in your graphics app that lets you record the individual steps performed on a single image, and then point the macro at a folder of source images and a folder to save the converted images.\u00a0 Photoshop has &#8220;batch processing&#8221; that handles this fine.\u00a0 Other programs (such as THE GIMP) are &#8220;scriptable&#8221; but some knowledge of Python is probably a must.<\/p>\n<p>So we now have a way to convert images en masse with a GUI app, but is it the most efficient way? Is it reusable? It is reusable but you&#8217;ll probably have to reset the macro\/batch settings if your source and destination folders change the next time you had to convert a lot of images.<\/p>\n<p><strong>Is there a quicker way to accomplish the same thing<\/strong> more or less?\u00a0 There is, in my opinion, a better way perform mass image conversion in a predictable, reliable way.\u00a0 It requires the command line terminal and an application known as &#8220;<strong>ImageMagick<\/strong>&#8220;.<\/p>\n<p>Using Linux (the <strong>bash shell<\/strong> and <strong>ImageMagick<\/strong>) here are the 2 steps:<\/p>\n<p>1. Use the &#8220;cd&#8221; command to get to the directory that has the bmp images<br \/>\n2. Issue this command:\u00a0 <strong>mogrify -format jpg *.bmp<\/strong><br \/>\nThe above command was found at <a title=\"Image Magick Batch Process\" href=\"http:\/\/www.ofzenandcomputing.com\/zanswers\/1016\" target=\"_blank\">http:\/\/www.ofzenandcomputing.com\/zanswers\/1016<\/a> and I thank them for posting it.\u00a0 It accomplished in one line the same work as a 50-line shell script.<br \/>\nResult: All of your bmp files have been converted and saved-as jpgs in the same directory<br \/>\nWarning: the &#8220;<strong>mogrify<\/strong>&#8221; command usually replaces the source, but when changing formats, Imagemagick is intelligent enough not to destroy the original bmp file.<\/p>\n<p>2a. To store the new files in a folder other than the source (e.g. &#8220;bmpFiles\/jpgs&#8221;), add the <strong>-path<\/strong> option in front of <strong>-format<\/strong>.\u00a0 The command becomes:\u00a0<strong> mogrify -path jpgs\/ -format jpg *bmp<\/strong><br \/>\nThe folder specified by -path must first exist, or the command will fail.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learning basic Linux commands helps save you time when working on repetitive tasks. Imagine you had a folder of images in *.bmp format.\u00a0 File sizes of bmps are larger than jpg files because they contain more information.\u00a0 To convert these bmp files to jpgs you could open a .bmp file in a graphics program (such [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,12,23],"tags":[26,28,27],"class_list":["post-191","post","type-post","status-publish","format-standard","hentry","category-command-line","category-learn-linux","category-use-linux","tag-commands","tag-graphics","tag-imagemagick"],"_links":{"self":[{"href":"https:\/\/nylinuxhelp.com\/blogs\/wp-json\/wp\/v2\/posts\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nylinuxhelp.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nylinuxhelp.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nylinuxhelp.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nylinuxhelp.com\/blogs\/wp-json\/wp\/v2\/comments?post=191"}],"version-history":[{"count":24,"href":"https:\/\/nylinuxhelp.com\/blogs\/wp-json\/wp\/v2\/posts\/191\/revisions"}],"predecessor-version":[{"id":215,"href":"https:\/\/nylinuxhelp.com\/blogs\/wp-json\/wp\/v2\/posts\/191\/revisions\/215"}],"wp:attachment":[{"href":"https:\/\/nylinuxhelp.com\/blogs\/wp-json\/wp\/v2\/media?parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nylinuxhelp.com\/blogs\/wp-json\/wp\/v2\/categories?post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nylinuxhelp.com\/blogs\/wp-json\/wp\/v2\/tags?post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}