{"id":67101,"date":"2022-09-10T09:00:30","date_gmt":"2022-09-10T09:00:30","guid":{"rendered":"https:\/\/www.cryptocabaret.com\/?p=67101"},"modified":"2022-09-10T09:00:30","modified_gmt":"2022-09-10T09:00:30","slug":"5-ways-to-resize-and-optimize-images-for-the-web-on-linux","status":"publish","type":"post","link":"https:\/\/www.cryptocabaret.com\/?p=67101","title":{"rendered":"5 ways to resize and optimize images for the web on Linux"},"content":{"rendered":"<p><span class=\"field field--name-title field--type-string field--label-hidden\">5 ways to resize and optimize images for the web on Linux<\/span><br \/>\n<span class=\"field field--name-uid field--type-entity-reference field--label-hidden\"><a title=\"View user profile.\" href=\"https:\/\/opensource.com\/users\/seth\" class=\"username\">Seth Kenlon<\/a><\/span><br \/>\n<span class=\"field field--name-created field--type-created field--label-hidden\">Sat, 09\/10\/2022 &#8211; 03:00<\/span><\/p>\n<div class=\"clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item\">\n<p>There was a time when 5 MB was the reasonable maximum size for an email attachment. Today, it&#8217;s easily possible for a single photo to be 5 MB. Accordingly, the maximum attachment size has increased to, say, 25 MB. But of course file sizes are getting bigger and bigger too, and so eventually the attachment limit will go up too. It&#8217;s an endless cycle, common in the digital world: the tools are built for today&#8217;s data, and today&#8217;s data increases in complexity and size until the tools are revised and improved. You have to contain data, preferably in the smallest packaging possible, so that sharing it online goes faster for everyone. Here are five ways to optimize images for the Internet.<\/p>\n<h2>What image size is good for the web?<\/h2>\n<p>First of all, there are two kinds of &#8220;sizes&#8221; when discussing digital images. The <em>image size<\/em> represents how many pixels wide and high an image is when you look at it on your screen. The <em>file size<\/em> represents how many bytes on a hard drive or SD card the image uses. It&#8217;s the <em>file size<\/em> that limits how easy something is to send it over the Internet because we all have different bandwidth allotments from our Internet providers and infrastructure. Of course, the larger the <em>image size<\/em>, the larger the <em>file size<\/em>, so the two are related.<\/p>\n<p>To avoid confusion, in this article I use the term &#8220;image size&#8221; to refer to the pixel width and height of an image, and the term &#8220;file size&#8221; to refer to the bytes on a hard drive occupied by an image file.<\/p>\n<p>It&#8217;s hard to know exactly what a &#8220;reasonable&#8221; image size and file size is for a photo on the Internet or being sent over email. There are some reasonable expectations, though. If you&#8217;re posting a photo to a website, whether it&#8217;s your own blog or to social media, it&#8217;s probable that <em>most<\/em> people are going to be viewing the photo at a resolution consistent with whatever&#8217;s in stores. Your screen size, at least in 2022, is probably 1920 by 1080 (high definition, or HD) or thereabouts. Your photo, then, probably doesn&#8217;t need to be any bigger than 1920 by 1080. Even people with a screen twice as big as yours could let your photo take up <em>half<\/em> their screen, which is probably sufficient.<\/p>\n<p>The other part of the equation is the file format. Many file formats, like JPEG and PNG, imply a certain amount of compression. The more compression, the smaller the file size, but too much compression can render a blurry image. I like the <a href=\"https:\/\/opensource.com\/article\/20\/4\/webp-image-compression\">WEBP<\/a> format, which tends to have quality better than JPEG at a smaller file size. It&#8217;s well supported by image applications and all major web browsers.<\/p>\n<\/p>\n<div class=\"embedded-resource-list callout-float-right\">\n<div class=\"field field--name-title field--type-string field--label-hidden field__item\">More Linux resources<\/div>\n<div class=\"field field--name-links field--type-link field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/cheat-sheets\/linux-commands-cheat-sheet\/?intcmp=70160000000h1jYAAQ\">Linux commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/cheat-sheets\/advanced-linux-commands\/?intcmp=70160000000h1jYAAQ\">Advanced Linux commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/services\/training\/rh024-red-hat-linux-technical-overview?intcmp=70160000000h1jYAAQ\">Free online course: RHEL technical overview<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/cheat-sheet-networking?intcmp=70160000000h1jYAAQ\">Linux networking cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/cheat-sheet-selinux?intcmp=70160000000h1jYAAQ\">SELinux cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/linux-common-commands-cheat-sheet?intcmp=70160000000h1jYAAQ\">Linux common commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/resources\/what-are-linux-containers?intcmp=70160000000h1jYAAQ\">What are Linux containers?<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/linux?intcmp=70160000000h1jYAAQ\">Our latest Linux articles<\/a><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<h2>1. Resize an image with Krita<\/h2>\n<p>The open source application <a href=\"http:\/\/krita.org\/\">Krita<\/a> is technically a digital painting application but it happens to be <a href=\"https:\/\/opensource.com\/article\/21\/12\/open-source-photo-editing-krita\">a really great photo editor<\/a> as well. I use it to load a photo, shrink it down to a reasonable size, and then save it in a web-optimized format.<\/p>\n<p>Three easy steps:<\/p>\n<ol class=\"arabic\">\n<li>\n<p>Go to the <strong>File<\/strong> menu and select <strong>Open<\/strong> to open your image in Krita.<\/p>\n<\/li>\n<li>\n<p>Go to the <strong>Image<\/strong> menu and select <strong>Scale image to new size<\/strong>. Type in the maximum width or height you want to resize your image to.<\/p>\n<\/li>\n<li>\n<p>Go to the <strong>File<\/strong> menu and select <strong>Save As<\/strong> and save the image as a WEBP image. Krita is smart and switches to WEBP as long as you use the <code>.webp<\/code> extension while saving your file (for example, <code>myphoto.webp<\/code>.)<\/p>\n<\/li>\n<\/ol>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/opensource.com\/sites\/default\/files\/2022-09\/krita-resize.webp\" width=\"475\" height=\"429\" alt=\"Resize an image with Krita\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(Seth Kenlon, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<p><a href=\"http:\/\/krita.org\/\">Krita<\/a> is available for Linux, Windows, and macOS.<\/p>\n<h2>2. Resize an image with GIMP<\/h2>\n<p>The open source <a href=\"http:\/\/gimp.org\/\">GNU Image Manipulation Program (GIMP)<\/a> is a photo editor, and it can resize images.<\/p>\n<p>Three easy steps:<\/p>\n<ol class=\"arabic\">\n<li>\n<p>Go to the <strong>File<\/strong> menu and select <strong>Open<\/strong> to open your image.<\/p>\n<\/li>\n<li>\n<p>Go to the <strong>Image<\/strong> menu and select <strong>Scale image<\/strong>. Type in the maximum width or height you want to resize your image to.<\/p>\n<\/li>\n<li>\n<p>Go to the <strong>File<\/strong> menu and select <strong>Export As<\/strong> and save the image as a WEBP image. The application is smart and uses WEBP as long as you give the <code>.webp<\/code> extension while saving your file (for example, <code>myphoto.webp<\/code>.)<\/p>\n<\/li>\n<\/ol>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/opensource.com\/sites\/default\/files\/2022-09\/gimp-resize.webp\" width=\"379\" height=\"339\" alt=\"Resize image in GNU Image Manipulation Program\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(Seth Kenlon, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<p><a href=\"http:\/\/gimp.org\/\">GNU Image Manipulation Program (GIMP)<\/a> is available for Linux, Windows, and macOS.<\/p>\n<h2>3. Resize an image with ImageMagick<\/h2>\n<p>The <a href=\"https:\/\/imagemagick.org\/\">ImageMagick<\/a> suite is a set of terminal commands that can manipulate images without even opening the files in a user interface. It&#8217;s a fast and efficient way to <a href=\"https:\/\/opensource.com\/article\/17\/8\/imagemagick\">modify lots of images all in one go<\/a>.<\/p>\n<p>One easy step:<\/p>\n<pre class=\"highlight\">\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span>convert <span class=\"nu0\">2022<\/span>-09-09-PHOTO.JPG <span class=\"re5\">-scale<\/span> 1920x myphoto.webp<\/code><\/span><\/pre>\n<p>In this command, <code>convert<\/code> is the component of ImageMagick that performs conversion, and <code>-scale<\/code> is the option that resizes. The <code>1080^<\/code> argument specifies that the converted image must be 1029 pixels wide, and the height (left blank after the <code>x<\/code> character) is auto-calculated.<\/p>\n<p><a href=\"https:\/\/imagemagick.org\/script\/download.php\">ImageMagick<\/a> is available for Linux, macOS, and Windows.<\/p>\n<h2>4. Archive an image<\/h2>\n<p>Sometimes you may not want to resize an image, but you still need to reduce the file size (the bytes the file uses up on your hard drive or SD card.) Images from consumer cameras, like those found in phones, are often already highly compressed, which doesn&#8217;t leave much for a computer to optimize without resizing it. However, professional cameras often shoot in formats that assume you want no or minimal compression, which means that you can reduce the file size of an image without loss of quality with a good archiving utility.<\/p>\n<p>There are several archive utilities out there, and many may already be installed on your computer. For instance, if your computer can create ZIP archives, then you&#8217;ve already got the ZIP compression algorithm available.<\/p>\n<p>Two easy steps:<\/p>\n<ol class=\"arabic\">\n<li>\n<p>Open a file manager on your computer and locate the photo you want to compress.<\/p>\n<\/li>\n<li>\n<p>Right-click on the photo, and select <strong>Compress<\/strong> (on some operating systems, this may called <strong>Archive<\/strong> instead.)<\/p>\n<\/li>\n<\/ol>\n<p>Provided there&#8217;s enough uncompressed data in your image to allow for compression, the archive version ought to be smaller in file size than the original. You can send the archive over the Internet, and the recipient can un-archive the image with<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/opensource.com\/sites\/default\/files\/2022-09\/gnome-compress.webp\" width=\"666\" height=\"446\" alt=\"Archiving a file\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(Seth Kenlon, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<p><a href=\"https:\/\/www.7-zip.org\/download.html\">7-zip<\/a> is an excellent archive tool for Linux, Windows, and <a href=\"https:\/\/formulae.brew.sh\/formula\/p7zip\">macOS<\/a>.<\/p>\n<h2>5. Split an image<\/h2>\n<p>If you&#8217;re a Linux user, you can use the <code>split<\/code> command to cut an image into a few different pieces of a specific file size. Then you can send the pieces to someone, and they can reassemble the file using the <code>cat<\/code> command.<\/p>\n<p>Assume the file <code>2022-09-09-PHOTO.JPG<\/code> is 6.7 MB. You could cut it into four pieces by splitting it at every 2 MB. On your computer:<\/p>\n<pre class=\"highlight\">\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ <span class=\"kw2\">split<\/span> <span class=\"nu0\">2022<\/span>-09-09-PHOTO.JPG <span class=\"re5\">--bytes<\/span> 2M<br>\n$ <span class=\"kw2\">ls<\/span> <span class=\"re5\">-l<\/span> <span class=\"re5\">--human<\/span><br><span class=\"br0\">[<\/span>...<span class=\"br0\">]<\/span> 6.7M Sep \u00a0<span class=\"nu0\">7<\/span> <span class=\"nu0\">14<\/span>:<span class=\"nu0\">50<\/span> <span class=\"nu0\">2022<\/span>-09-09-PHOTO.JPG<br><span class=\"br0\">[<\/span>...<span class=\"br0\">]<\/span> 2.0M Sep \u00a0<span class=\"nu0\">7<\/span> <span class=\"nu0\">14<\/span>:<span class=\"nu0\">54<\/span> xaa<br><span class=\"br0\">[<\/span>...<span class=\"br0\">]<\/span> 2.0M Sep \u00a0<span class=\"nu0\">7<\/span> <span class=\"nu0\">14<\/span>:<span class=\"nu0\">54<\/span> xab<br><span class=\"br0\">[<\/span>...<span class=\"br0\">]<\/span> 2.0M Sep \u00a0<span class=\"nu0\">7<\/span> <span class=\"nu0\">14<\/span>:<span class=\"nu0\">54<\/span> xac<br><span class=\"br0\">[<\/span>...<span class=\"br0\">]<\/span> 667K Sep \u00a0<span class=\"nu0\">7<\/span> <span class=\"nu0\">14<\/span>:<span class=\"nu0\">54<\/span> xad<\/div><\/div><\/pre>\n<p>On the recipient&#8217;s computer:<\/p>\n<pre class=\"highlight\">\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"kw2\">cat<\/span> xaa xab xac xad <span class=\"sy0\">&gt;<\/span> myphoto.jpg<\/code><\/span><\/pre>\n<h2>Save space<\/h2>\n<p>In the eternal struggle between file size and carrier capacity, it&#8217;s likely we&#8217;ll always have to make concessions. Using open source tools to save space either through lossy compression, lossless compressed archiving, or through clever work-arounds, is a great way to save space and maximize speed of communication. Sure, a picture is worth a thousand words, but it doesn&#8217;t have to take up a thousand megabytes!<\/p>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-field-article-subhead field--type-text-long field--label-hidden field__item\">\n<p>Resize, archive, and split images to make big files better for the Internet.<\/p>\n<\/div>\n<div class=\"field field--name-field-lead-image field--type-entity-reference field--label-hidden field__item\">\n<article class=\"media media--type-image media--view-mode-caption\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/09\/web_browser_desktop_devlopment_design_system_computer.jpg\" width=\"520\" height=\"292\" alt=\"web development and design, desktop and browser\" title=\"web development and design, desktop and browser\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p><a href=\"https:\/\/pixabay.com\/en\/users\/kreatikar-8562930\/\" target=\"_blank\" rel=\"ugc noopener\">kreatikar<\/a>\u00a0via <a href=\"https:\/\/pixabay.com\/en\/webdesign-design-web-website-3411373\/\" target=\"_blank\" rel=\"ugc noopener\">Pixabay<\/a>, <a href=\"https:\/\/pixabay.com\/en\/service\/terms\/#usage\" target=\"_blank\" rel=\"ugc noopener\">CC0<\/a><\/p>\n<\/div>\n<\/article>\n<\/div>\n<div class=\"field field--name-field-tags field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/art-and-design\" hreflang=\"en\">Art and design<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/linux\" hreflang=\"en\">Linux<\/a><\/div>\n<\/p><\/div>\n<div class=\"hidden field field--name-field-listicle-title field--type-string field--label-hidden field__item\">What to read next<\/div>\n<div class=\"field field--name-field-default-license field--type-list-string field--label-hidden field__item\"><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><br \/>\n        <img decoding=\"async\" alt=\"Creative Commons License\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/09\/cc-by-sa--11.png\" title=\"This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.\"><\/a>This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.<\/div>\n<section class=\"field field--name-field-comments field--type-comment field--label-hidden comment-wrapper\">\n<div class=\"comments__count\">\n<div class=\"login\"><a href=\"https:\/\/opensource.com\/user\/register?absolute=1\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml&amp;absolute=1\">Login<\/a> to post a comment.<\/div>\n<\/p><\/div>\n<\/section>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\" rel=\"noopener\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>5 ways to resize and optimize images for the web on Linux Seth Kenlon Sat, 09\/10\/2022 &#8211; 03:00 There was a time when 5 MB was the reasonable maximum size for an email attachment. Today, it&#8217;s easily possible for a single photo to be 5 MB. Accordingly, the maximum attachment size has increased to, say, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":67102,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307],"tags":[],"class_list":["post-67101","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-open-source"],"_links":{"self":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/67101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=67101"}],"version-history":[{"count":0,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/67101\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/media\/67102"}],"wp:attachment":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=67101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=67101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=67101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}