{"id":54,"date":"2008-04-18T00:07:25","date_gmt":"2008-04-17T21:07:25","guid":{"rendered":"http:\/\/www.held.org.il\/blog\/?p=54"},"modified":"2008-04-18T00:07:25","modified_gmt":"2008-04-17T21:07:25","slug":"basename-magic-mass-resize-images","status":"publish","type":"post","link":"http:\/\/www.held.org.il\/blog\/2008\/04\/basename-magic-mass-resize-images\/","title":{"rendered":"&quot;basename&quot; magic; mass resize images"},"content":{"rendered":"<p><strong>basename + dirname fun<br \/>\n<\/strong><\/p>\n<ul>\n<li>shell&gt; dirname \/long\/path\/file.jpeg<br \/>\noutput: \/long\/path<\/li>\n<li>shell&gt; basename \/long\/path\/file.jpeg<br \/>\noutput: file.jpeg<\/li>\n<li>shell&gt; basename \/long\/path\/file.jpeg .jpeg<br \/>\noutput: file<em><br \/>\n<\/em>This one is sooo amazing, ah?!<\/li>\n<\/ul>\n<p><strong><br \/>\nconvert<\/strong><\/p>\n<p><em>convert<\/em> tool comes with <a title=\"ImageMagick homepage\" href=\"http:\/\/www.imagemagick.org\">ImageMagick<\/a>. It allows extensive image-manipulation-by-command-line. I've just found out that it supports -resize<strong> xx<\/strong>% form, although not mentioned in manpage.<\/p>\n<p><strong>Putting it all together<\/strong><\/p>\n<p>The 2nd parameter of <em>basename<\/em> is really useful in mass-filename-scripts. Let's write a script for mass-resizing all jpegs to 50% of their original size:<\/p>\n<blockquote><p>for i in *.jpeg; do convert -resize 50% $i `basename $i .jpeg`-resized.jpeg; done<\/p><\/blockquote>\n<p><strong><br \/>\n<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>basename + dirname fun shell&gt; dirname \/long\/path\/file.jpeg output: \/long\/path shell&gt; basename \/long\/path\/file.jpeg output: file.jpeg shell&gt; basename \/long\/path\/file.jpeg .jpeg output: file This one is sooo amazing, ah?! convert convert tool comes with ImageMagick. It allows extensive image-manipulation-by-command-line. I&#8217;ve just found out that it supports -resize xx% form, although not mentioned in manpage. Putting it all together [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[75],"tags":[],"_links":{"self":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/54"}],"collection":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":0,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}