{"id":3008,"date":"2023-03-16T22:21:57","date_gmt":"2023-03-16T21:21:57","guid":{"rendered":"https:\/\/davidlebech.com\/thoughtflow\/?p=3008"},"modified":"2023-03-21T21:59:27","modified_gmt":"2023-03-21T20:59:27","slug":"web-friendly-images-with-imagemagick","status":"publish","type":"post","link":"https:\/\/davidlebech.com\/thoughtflow\/web-friendly-images-with-imagemagick\/","title":{"rendered":"Web-friendly images with ImageMagick"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Before uploading images to my blog or <a rel=\"noreferrer noopener\" href=\"https:\/\/aitales.hirobo.dev\/\" data-type=\"URL\" data-id=\"https:\/\/aitales.hirobo.dev\/\" target=\"_blank\">AI Tales<\/a>, I run them through ImageMagick to resize and convert them to &#8220;web-friendly&#8221; JPGs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>convert -format jpg \\                                \n    -strip \\       \n    -interlace Plane \\\n    -set filename:base \"%&#91;basename]\" \\\n    -quality 50% *.png \\\n    \"%&#91;filename:base].jpg\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The command converts all PNG images in a folder to JPG while preserving the filename. Even though quality is set to 50% (you can of course experience with this, I often don&#8217;t see a noticeable difference from the original &#8212; especially for images generated with AI such as Stable Diffusion.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And the size is reduced <em><strong>significantly<\/strong><\/em>. For example, I can sometimes reduce the size of PNG images by more than 90% (553kb to 39kb i a recent example).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are <a href=\"https:\/\/davidlebech.com\/thoughtflow\/simple-photo-effects-with-imagemagick\/\" data-type=\"post\" data-id=\"2796\">some more ImageMagick one-liners<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Before uploading images to my blog or AI Tales, I run them through ImageMagick to resize and convert them to &#8220;web-friendly&#8221; JPGs: The command converts all PNG images in a folder to JPG while preserving the filename. Even though quality is set to 50% (you can of course experience with this, I often don&#8217;t see [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[228,66],"class_list":["post-3008","post","type-post","status-publish","format-standard","hentry","category-tips","tag-imagemagick","tag-photos"],"_links":{"self":[{"href":"https:\/\/davidlebech.com\/thoughtflow\/wp-json\/wp\/v2\/posts\/3008","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davidlebech.com\/thoughtflow\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davidlebech.com\/thoughtflow\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davidlebech.com\/thoughtflow\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davidlebech.com\/thoughtflow\/wp-json\/wp\/v2\/comments?post=3008"}],"version-history":[{"count":2,"href":"https:\/\/davidlebech.com\/thoughtflow\/wp-json\/wp\/v2\/posts\/3008\/revisions"}],"predecessor-version":[{"id":3010,"href":"https:\/\/davidlebech.com\/thoughtflow\/wp-json\/wp\/v2\/posts\/3008\/revisions\/3010"}],"wp:attachment":[{"href":"https:\/\/davidlebech.com\/thoughtflow\/wp-json\/wp\/v2\/media?parent=3008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davidlebech.com\/thoughtflow\/wp-json\/wp\/v2\/categories?post=3008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davidlebech.com\/thoughtflow\/wp-json\/wp\/v2\/tags?post=3008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}