There are two ways you can “lossily” compress your images ġ. The good thing is that with Jpegoptim you can specify how much quality loss you are ok with. Sometimes we want to compress our images knowing that the process will not be lossless. This ensures that the jpeg command with the -n flag only displays the future compression percentage and size without actually compressing the image. When I rechecked its size after using the jpegoptim command as above, I saw no change in its size. Then, I will use the -n flag with the jpegoptim command to know about its potential compression. I will print its size first through the du command as follows: $ du sample.jpg The following example will further explain the process: The following command will not actually compress the image, it will just tell you how much the image will be compressed if you ever try to compress it with Jpegoptim. If you want to see, beforehand, how much an image is capable of being compressed, you can simulate image compression through Jpegoptim. The above command will compress and save my sample.jpg file to an already existing folder named “compressed”. You can then use the following command syntax to perform the compression: If you want them to be saved to an already existing folder then you do not need to create a new one. If you are afraid that you will lose your original image because Jpegoptim will overwrite it, you can tell the tool to save the compressed image to another folder.įirst, create a folder where you want the compressed images to be saved. Here is how the output would look like in such a situation: However, Jpegoptim will start skipping the compression if it reaches the limit where you have a lossless image quality with the most compression. If you want the image to be compressed even further, you can run the same command again.
Note: Please keep in mind that the tool overwrites the existing image, so it is a good idea to have the original image saved somewhere else. If you want to compress a single image without wanting to compromise on the quality, use the following command: Let us now explore the power of Jpegoptim through the following ways you can use it: Losslessly compress a single image You can check the version number of the application, and also verify that it is indeed installed on your system, through the following command: Advertisement $ jpegoptim -version The process may, however, take some time depending on your Internet speed.
Enter Y and then hit enter the software will be installed on your system.
The system might ask you the password for sudo and also provide you with a Y/n option to continue the installation.
Now you are ready to install Image Jpegoptim you can do so by running the following command as sudo: $ sudo apt-get install jpegoptim Please note that only an authorized user can add, remove and configure software on Ubuntu. This helps you in installing the latest available version of a software from the Internet.
The next step is to update your system’s repository index through the following command: $ sudo apt-get update Open your Terminal application either through the system Application Launcher Search or through the Ctrl+Alt+T shortcut. Jpegoptim is easily available through the official Ubuntu repository and can be easily installed through the command line using the apt-get command. We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system. The article will also enable you in writing and executing a bash script that will automate the process of compressing all jpegs located in a single directory. We will also explain various ways in which you can use this application to optimize and compress your jpeg image files. In this article, we will describe how you can install the command line utility Jpegoptim on Ubuntu. Jpegoptim can help you in compressing your jpegs, jpg, and jfif files with and without quality loss, depending on what you are looking for. This is especially useful for the Terminal-savvy who like to perform their tasks using minimum system resources. Graphic designers also have to deal with the same issue but they are well-equipped with tools that can compress the images so that they can be easily shared with the stakeholders.įor Ubuntu, there are many graphical utilities that would let you optimize and compress your jpegs but here we will be discussing a command-line tool called Jpegoptim. The real deal comes when we have to share these images, upload them on a cloud facility, or even save them on a device with restricted storage. The image resolution capability of today’s photo capturing devices like smartphones and digital cameras is increasing day by day.