{"title":"Stanley Solutions Blog - Scripting","link":[{"@attributes":{"href":"https:\/\/blog.stanleysolutionsnw.com\/","rel":"alternate"}},{"@attributes":{"href":"https:\/\/blog.stanleysolutionsnw.com\/feeds\/scripting.atom.xml","rel":"self"}}],"id":"https:\/\/blog.stanleysolutionsnw.com\/","updated":"2024-01-24T20:52:00-08:00","subtitle":"engineering and creativity - all under one hat","entry":{"title":"Quick-n-Simple Photo Converter (for HEIC format)","link":{"@attributes":{"href":"https:\/\/blog.stanleysolutionsnw.com\/quick-n-simple-photo-converter.html","rel":"alternate"}},"published":"2024-01-24T20:52:00-08:00","updated":"2024-01-24T20:52:00-08:00","author":{"name":"Joe Stanley"},"id":"tag:blog.stanleysolutionsnw.com,2024-01-24:\/quick-n-simple-photo-converter.html","summary":"<p>Those techy, geeks in the audience that use an iPhone probably recognize that the photos they take are in a format that's generally a little... Tricky to use with other resources. Seems I most frequently run into this issue when working on updating my blog with pictures that I took on my phone. I really would much rather use a <code>.png<\/code> format in place of the somewhat irksome <code>.heic<\/code> format that my iPhone captures. There's plenty of things online that I could upload my photos too, but who really wants to do that? I'd rather use something a little more \"close to home.\"<\/p>","content":"<p>I end up taking lots of pictures. Maybe not as many as some folks, but I do take a lot... Pretty much all of those pictures are taken with my iPhone. As such, they're all in\nthe <a href=\"https:\/\/en.wikipedia.org\/wiki\/High_Efficiency_Image_File_Format\"><code>.heic<\/code> (high efficiency image) format<\/a>. Now, that's neat and all, but those images are harder to embed\nin all the places I want to put them. Thus, I'm stuck back-converting them to <a href=\"https:\/\/en.wikipedia.org\/wiki\/PNG\">PNG format<\/a>.<\/p>\n<p>Like any good programmer, I went right to Google to do a little \"lookin' around\" to find a way to do this with locally on a Linux machine.<\/p>\n<p>Didn't take long to find plenty of articles recommending <code>heif-convert<\/code>, which can be installed with the following command:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>sudo<span class=\"w\"> <\/span>apt<span class=\"w\"> <\/span>install<span class=\"w\"> <\/span>libheif-examples\n<\/code><\/pre><\/div>\n\n<p><strong>GREAT!<\/strong><\/p>\n<p>... but ...<\/p>\n<p>It's a touch too long for my impatient fingers, and I don't want to run that same command over, and over, and over, and over, and over again...<\/p>\n<blockquote>\n<p>Time for a script!<\/p>\n<\/blockquote>\n<p>I decided to make a simple little script to find all of the <code>*.heic<\/code> photos in the specified directory, and run the conversion required...<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"ch\">#!\/usr\/bin\/bash<\/span>\n<span class=\"c1\"># Simple HEIC Conversion Utility (so Joe doesn&#39;t need to remember)<\/span>\n<span class=\"k\">for<\/span><span class=\"w\"> <\/span>file<span class=\"w\"> <\/span><span class=\"k\">in<\/span><span class=\"w\"> <\/span><span class=\"nv\">$1<\/span>\/*.HEIC\n<span class=\"k\">do<\/span>\n<span class=\"w\">    <\/span><span class=\"nb\">echo<\/span><span class=\"w\"> <\/span><span class=\"s2\">&quot;Converting: <\/span><span class=\"nv\">$file<\/span><span class=\"s2\">&quot;<\/span>\n<span class=\"w\">    <\/span>heif-convert<span class=\"w\"> <\/span><span class=\"s2\">&quot;<\/span><span class=\"nv\">$file<\/span><span class=\"s2\">&quot;<\/span><span class=\"w\"> <\/span><span class=\"s2\">&quot;<\/span><span class=\"si\">${<\/span><span class=\"nv\">file<\/span><span class=\"p\">%.*<\/span><span class=\"si\">}<\/span><span class=\"s2\">.png&quot;<\/span>\n<span class=\"w\">    <\/span>rm<span class=\"w\"> <\/span><span class=\"nv\">$file<\/span>\n<span class=\"k\">done<\/span>\n<\/code><\/pre><\/div>\n\n<blockquote>\n<p><a href=\"https:\/\/github.com\/engineerjoe440\/stanley-solutions-blog\/tree\/master\/photo-convert\"><code>photo-convert<\/code> script<\/a><\/p>\n<\/blockquote>\n<p>This really made for a nice, handy little script for my photo conversion needs. Maybe you'll find it helpful, too!<\/p>","category":[{"@attributes":{"term":"Scripting"}},{"@attributes":{"term":"blog"}},{"@attributes":{"term":"website"}},{"@attributes":{"term":"shell"}},{"@attributes":{"term":"script"}},{"@attributes":{"term":"heic"}},{"@attributes":{"term":"image"}},{"@attributes":{"term":"photo"}},{"@attributes":{"term":"converter"}},{"@attributes":{"term":"conversion"}},{"@attributes":{"term":"file"}},{"@attributes":{"term":"iphone"}}]}}