How to reduce the size of a picture or image? Maximum compression! The good old JPEG, despite a lot of undeniable advantages, still has significant limitations. A new method of image compression, the development of which had already been carried out for a long time, was called upon to remove them.

Old good JPEG, despite a lot of undeniable advantages, it still has significant limitations. Was called upon to remove them new method image compression, which has been in development for a long time. Now that JPEG2000 has become an officially recognized format, this should serve as the beginning of its active support by various software manufacturers.

Surely many who work with graphics on a computer are interested in the question: how can an image that occupies a very impressive amount of space in the PC memory be squeezed into a much smaller size on the disk? I remember that at the dawn of my publishing career, the word “compression” was so mysterious and amazing for me... In fact, how does image compression occur? After all, without it it is now unthinkable to imagine either the Network or digital photography, nor color printing?

So, compression. It may or may not lead to a loss of quality. The last case is methods such as RLE (Run Length Encoding, encoding run lengths, which results in pairs like ( skip, value, Where skip is the number of consecutive zeros, and value- the value following them) and LZW (compression using the Lempel-Ziff-Welch method), implemented in PSD, GIF and TIFF formats. They are also widely used by archivers such as RAR and ZIP. The average degree of lossless compression is 2-3 times.

If you need to compress an image more, you cannot do without losing quality. What are the principles? Firstly, any image contains a certain redundancy, the removal of which will not lead to a noticeable change in the quality of the image. Secondly, the human eye is more sensitive to changes in brightness than color. Therefore for different channels Various degrees of compression are applied to images - information is lost, but this is not visually noticeable. In addition, the eye's sensitivity to small image elements is low, which makes it possible to remove them without compromising quality. This way you can compress the image (even if the deterioration in quality is already noticeable) up to an acceptable threshold. The degree of quality degradation is determined for each specific case. For printing, only minimal distortions are allowed, but for posting on the Internet (depending on the purpose) - much more.

The most popular among lossy compression methods is JPEG, which, even with thirtyfold compression, retains sufficient image quality. By the way, in most modern methods data compression (for example, Layer-4, known as mp3, as well as MPEG) implement mechanisms similar to JPEG. Let's take a closer look at this format, especially since not so long ago its newest implementation, JPEG2000, was finally approved, which included all the additions made to JPEG/MPEG over ten years of its development.

JPEG

The name of the compression algorithm is an abbreviation for the Joint Photographic Expert Group, an initiative group formed from experts from the ITU (International Telecommunication Union) and ISO (International Organization for Standardization). That is why its name contains the prefix Joint. In 1992, JPEG was declared the international standard for graphics.

When compressing using the JPEG method, quality is always lost. In this case, there is always a choice: to give preference to quality at the expense of volume (the file size will be compressed approximately three times) or, on the contrary, to achieve minimum size image in which it will still remain recognizable (the degree of compression can reach 100). Compression, in which the difference in quality between the resulting image and the original is still unnoticeable, results in a 10-20 times reduction in file size.

Application area

JPEG is the best compressor for photographic-quality full-color and monochrome images. If you want to save an image with an index palette, it is first converted to full color. When compressing using the JPEG method, you need to keep in mind that everything depends on the nature of the images: much less volume will be occupied by those where the color changes are insignificant and there are no sharp color transitions. JPEG is used wherever photographic images need to be stored: in digital cameras, printing (EPS DCS 2.0), the Internet is unthinkable without it.

There are several types of JPEG compression, but we will consider only two of them, used in the standard package for working with raster images Adobe Photoshop, — baseline And progressive. The other two methods - ariphmetic and loseless - are exotic, and for a number of reasons have not become widespread.

How does compression occur?

1. The first stage is color model conversion images (usually RGB) into a model where the brightness and color components are separated (for example, YCbCr or YUV), which allows for an optimal choice of compression levels for each channel (taking into account the characteristics of eye perception). The conversion occurs as follows:

Y = 0.299xR+0.587*G+0.114xB Cb = (B-Y)/0.866/2+128 Cr = (R-Y)/0.701/2+128

2. At the next stage, the so-called prefiltration, in which neighboring pixels separately in each of the Cb and Cr channels are grouped in pairs in the horizontal and vertical directions, and the brightness channel Y is left unchanged. After this, the entire group of four pixels receives the average value of the corresponding Cb and Cr components. For brevity, such a scheme can be designated as 4:1:1 (the same form of representation is adopted in DRAW - the jpeg export window). Taking into account the fact that each pixel is encoded with 3 bytes (256 levels for each of the three channels), as a result, the amount of data is automatically reduced by 2 times (instead of 12 bytes, to transfer 4 pixels it is enough to transfer only 4+1+1 = 6 bytes) . From a mathematical point of view, such a transformation leads to a significant loss of information, but the human eye does not perceive the loss, since there is significant redundancy in ordinary photographic images.

3. The received information, which has passed the stage of primary “cleaning”, is separately grouped in each channel again into blocks, but already 8x8 in size, after which basic compression is applied to them - the so-called. discrete cosine transform, for short - DCT (discrete cosine transform). As a result, information about distribution pixel brightness is converted to another form, where it is described by a distribution based on frequency of occurrence one or another pixel brightness. DCT has a number of advantages over other transforms (for example, the Fourier transform), providing better information recovery.

Instead of an array of 64 values ​​(8x8 pixels) for each block that makes up the image, we get an array of 64 frequencies. Let's look at how DCT works using an example. Let's say the brightness of the pixels in one block of our image has the form shown in Fig. 1 on the left, then the result of the transformation will be as shown on the right.

1

Despite significant accuracy, some loss of information does occur at this stage - this is why JPEG always leads to loss of quality. The main purpose of the transformation is to find out the overall picture of the distribution of large (in the figure - top left) and small (bottom right) objects, which will be useful later when eliminating unimportant information.

4. The next stage is removing information that is barely noticeable to the eye from the block, or quantization(quantization). All components are divided into various coefficients that determine the significance of each of them for high-quality restoration of the original image, and the result rounded up up to an integer value. It is this procedure that introduces the greatest loss of quality, reducing the final volume of the image. High-frequency components are quantized roughly, while low-frequency components are quantized more accurately, since they are most noticeable. In order to somewhat smooth out the decrease in quality, the luminance channel uses smaller division factors than the chrominance channels. But more often (this is done to speed up calculations), instead of specially selected values, only one is taken - the one entered by the user when choosing the degree of compression.

For example, this is what it looks like Photoshop window when saving an image using the Save for web operation, where the Quality parameter (or rather, a derivative of it) is the same rounding factor(Fig. 2).

As a result of quantization, a set of components is obtained, from which the original image is reconstructed with a given accuracy (Fig. 3).

4

In Fig. Figure 4 shows the result of reconstructing a black and white square using one, four and fifteen components, respectively.

5. After the main work of image compression has been completed, further transformations are reduced to secondary tasks: the remaining components are collected in sequence in such a way that those responsible for large parts are located first, and then for all the smaller ones. If you look at the picture, the movement of the encoder looks like a zigzag line. This stage is called ZigZag (Fig. 5).

5

Then the resulting sequence is compressed: first with the usual RLE, then with the Huffman method.

6. And finally, clean technical stage— the data is enclosed in a shell and provided with a header, which indicates all the compression parameters so that the image can be restored. However, sometimes this information is not included in the headers, which gives additional benefits in compression, but in this case you need to be sure that the application that will read the file knows about them.

That, in general, is all the transformation. Now let's calculate what compression was achieved in our example. We received 7 values ​​from which the original 8x8 image will be restored. So, the compression from the use of DCT transformation in both color channels was 8x8/7 9 times. Let's allocate not seven, but 11 coefficients to the brightness channel, which will give 8x8/11 6. For all three channels it will be (9+9+6)/3=8 times. The reduction in quality during the “thinning” of the image, which occurred at the second stage, gives an additional double increase (the 4-1-1 scheme, taking into account the peculiarities of encoding the brightness component), which will give a final result of 16 times. This is a rough calculation that does not take into account some aspects, but reflects the real picture. To get a thirty-fold reduction in file size, you need to leave only 3-4 components.

The image restoration process takes place in reverse order: First, the components are multiplied by the values ​​from the quantization table, and the approximate coefficients for the inverse cosine transform are obtained. The better the quality selected during compression, the higher the degree of approximation to the original coefficients, which means the image will be restored more accurately. There is only one action left to add: just before completion, make some adjustments (noise) to the boundary pixels from neighboring blocks in order to remove sharp differences between them.

Disadvantages of JPEG

  1. Inability to achieve high compression rates due to block size restrictions (8x8 only).
  2. Blocky structure at high levels of compression.
  3. Rounds sharp corners and blurs fine elements in an image.
  4. Only RGB images are supported (JPEG for CMYK images can only be used in EPS format via DCS).
  5. The image cannot be displayed until it is completely loaded.

It's been ten years since JPEG was approved as a standard. During this time, groups of researchers proposed a number of significant additions to the original version, which resulted in the emergence of a new standard at the end of last year.

JPEG2000

Since 1997, work began aimed at creating a universal encoding system that would remove all the limitations imposed by JPEG and could effectively work with all types of images: black and white, grayscale, full color and multi-component, regardless of content ( whether these will be photographs, fairly small text, or even drawings). Along with international standardizing organizations, such industry giants as Agfa, Canon, Fujifilm, Hewlett-Packard, Kodak, LuraTech, Motorola, Ricoh, Sony, etc. took part in its development.

Because the new algorithm claimed to be universal, he was additionally tasked with using various methods of data transmission (in real mode time and with a narrow bandwidth), which is especially critical in multimedia applications, for example, in real broadcasts over the Internet.

Basic requirements for the JPEG2000 format:

  1. Achieving a higher degree of compression compared to JPEG.
  2. Supports monochrome images, which will allow you to use it to compress images with text.
  3. Possibility of compression without loss at all.
  4. Outputs images with gradual improvement in detail (as in progressive GIF).
  5. The use of priority areas in the image, for which the quality can be set higher than the rest of the image.
  6. Decoding in real time (no delays).

Compression principle

The main compression mechanism in JPEG2000, unlike JPEG, uses wavelet transformation - a system of filters applied to the entire image. Without going into details of compression, we will only note the main points.

6
First, in the same way as for JPEG, the image is converted into the YCrCb system, after which the initial removal of redundant information occurs (by already known combining adjacent pixels into 2x2 blocks). Then the entire image is divided into parts of the same size (tile), each of which, independently of the others, will undergo further transformations (this reduces the requirements for memory and computing resources). Next, each channel is filtered by low-pass and high-pass filters separately in rows and rows, as a result of which, after the first pass, four more are formed in each part small images(subband). All of them carry information about the original image, but their information content is very different (Fig. 6).

For example, the image obtained after low-pass filtering by rows and rows (top left) bears the most large quantity information, and what is received after high-frequency is minimal. The information content of images obtained after low-pass filtering of rows and high-pass filtering of columns (and vice versa) is average. The most informative image is again filtered, and the resulting components, as with jpeg compression, are quantized. This happens several times: for lossless compression the cycle is usually repeated 3 times, with losses - 10 iterations are considered a reasonable compromise between size, quality and decompression speed. The result is one small image and a set of pictures with small details, consistently and with a certain accuracy restoring it to normal size. Obviously, the highest degree of compression is obtained on large images, since a larger number of cycles can be set.

Practical implementation

Since the foundations of JPEG2000 compression were laid, a number of companies have developed fairly effective algorithms for its implementation.

Among the major software developers, Corel can be noted (by the way, it was one of the first to introduce into its packages support for the wi format, based on wave transformations, for which it is honored and praised) - all images are supplied on CDs with the CorelDRAW package up to the ninth version , were compressed in exactly this way.

Later, Adobe joined in. Some of the ideas contained in JPEG2000 were applied by the developers of Photoshop 6 in the form of advanced options when saving an image in JPEG format(usual, based on cosine transformation). Among them is progressive JPEG (the Progressive option in the Save for Web window). This algorithm is intended primarily for real-time systems and works exactly the same as progressive GIF. First, a rough copy of the image appears, consisting of just a few large blocks, and over time, as the rest of the data is loaded, the structure begins to be viewed more clearly until, finally, the final image is completely restored. Unlike GIF, this algorithm places a greater burden on the viewer, since it will have to complete the entire transformation cycle for each version transmitted.

Among other additions, we note the inclusion in the file of several JPEG-compressed images with varying degrees of compression, resolution, and even color models. Accordingly, in Photoshop 6 it became possible to select individual areas in an image and apply different compression settings to them ( Region-Of-Interest, such a mechanism was first proposed back in 1995), using lower values ​​in the quantization table. To do this, set the required area (for example, in the form of a new channel in the image) and click the mask icon next to the Quality item. In the window that appears, you can experiment with the image by moving the sliders - the finished result is displayed on the screen, allowing you to quickly find the necessary compromise between quality and size.

Specialized converters and viewers

Since the standard does not stipulate specific implementations of compression/decompression methods, this gives scope to third-party developers of compression algorithms. In fact, you can use either a simplified wave conversion algorithm and thereby speed up the compression process, or, conversely, use a more complex one and, accordingly, requiring large system resources.

Specialized solutions from other companies are available as commercial developments. Some are implemented in the form individual programs(JPEG 2000 developed by Aware), others - in the form of additional modules for the most common raster editors (ImagePress JPEG2000 developed by Pegasus Imaging and the LEAD JPEG2000 module from LEAD Technologies). The company LuraTech, which has been working on this issue for a long time, stands out against their background. It promotes its LuraWave technology in the self-contained product LuraWave SmartCompress (the third version is already available) and offers modules for Photoshop, Paintshop, Photopaint. Distinctive feature - more high speed work (almost instant conversion) even with images several megabytes in size. Accordingly, the price of this module is the highest - $79.

To view JPEG2000 images in browsers, you need to install a special viewer module (all developers offer it for free). Inserting an image into an HTML document, like any plug-in, comes down to using the EMBED construct (with additional parameters). For example, means that a progressive image transmission method will be used. That is, in our example (a file of 139 KB in size), first only 250 bytes are transferred, on the basis of which a rough image will be built, then, after loading 500 bytes, the image is updated (this continues until the LIMIT value is reached).

If you want to get more high quality image, you need to select the Improve item from the menu that pops up using the right button (Fig. 9). In four downloads, the entire image will be downloaded completely.

9

conclusions

So, JPEG2000 objectively shows top scores than JPEG only at high compression levels. With compression of 10-20 times, there is not much difference. Will it be able to displace or simply compete with the widespread format? In the near future - it’s unlikely; in most cases, the quality/size ratio provided by JPEG is quite acceptable. And those 10-20% additional compression that JPEG2000 provides with visually the same quality are unlikely to lead to an increase in its popularity.

But digital camera manufacturing companies are showing keen interest in the new format, since the size of light-sensitive matrices is steadily increasing every year, and it is becoming increasingly difficult to store images in memory. And then the new format will become more widespread, and who knows, perhaps after some time JPEG2000 will become equal to JPEG. In any case, Analog Micro Devices recently released a specialized chip in which compression/decompression according to new technology implemented at the hardware level, and the US Department of Defense is already actively using the new format for recording photographs received from spy satellites.

Facts and speculation

1. JPEG loses quality when opening and resaving the file.

Not true. Quality is only lost when a compression level less than the one with which the image was saved is selected.

2. JPEG loses quality when editing the file.

Is it true. When you save the modified file, all transformations are performed again - so avoid frequent image editing. This only applies when the file is closed; if the file remains open, there is no cause for concern.

3. The result of compression with the same parameters in different programs will be the same.

Not true. Different programs interpret user input differently. For example, in one program the quality of the saved image is indicated (as, for example, in Photoshop), in another - the degree of its compression (the inverse value).

4. When installing maximum quality the image is saved without any loss of quality.

Not true. JPEG always compresses with losses. But setting, for example, 90% quality instead of 100% results in a reduction in file size greater than the deterioration in quality perceived by the eye.

5. Any JPEG file can be opened in any editor that understands the JPEG format.

Not true. This type of JPEG, called progressive JPEG, is not understood by some editors.

6. JPEG does not support transparency.

Is it true. Sometimes it may seem that some part of the image is transparent, but in fact its color is simply chosen to match the background color in the html page.

7. JPEG compresses better than GIF.

Not true. They have different areas of application. IN general case, a typical “GIF” picture after converting to JPEG will have a larger volume.

JPEG2000 vs JPEG

7
1. With twenty to thirty times compression, JPEG2000 and JPEG give approximately the same quality (by the way, Photoshop cannot compress a regular photo beyond this limit).

2. With higher compression, the quality of JPEG2000 is significantly higher than that of JPEG, which allows you to compress up to 50 times without any losses, and with some losses (we are talking about images for the Internet) - up to 100 and even up to 200.

3. At high levels of compression in those areas where a smooth color change occurs, the image does not acquire the block structure characteristic of a simple JPEG. JPEG2000 also somewhat smears and rounds out sharp edges - see photographs (Fig. 7 and 8).

It shows the results of compression of a test file with different degrees of compression (on the left - saved in Photoshop in JPG format, on the right - in JPEG2000 format). For the image in Fig. 7, compression levels of 20, 40, 70 and 145 were selected (they can be explicitly specified when saving in JPEG2000), the JPG compression level was chosen so that the file size was the same as after compression using JPEG2000. As they say, the results are obvious. For clarity, a second experiment was carried out on an image with sharper details (with compression levels of 10, 20, 40 and 80). The advantage is again on the side of JPEG2000 (Fig. 8).

8

4. Since, in fact, copies with different resolutions are stored in one JPEG2000 file

I mean, for those who make image galleries on the Internet, there is no need to create thumbnails for them.

5. Of particular interest is compression without distortion (loseless mode). Thus, the test file with LZW compression from Photoshop took 827 KB, and the compressed JPEG2000 took 473 KB.

6. Compared to JPEG, its more advanced namesake consumes significantly more system resources. But the power of computers, which has significantly increased over the past couple of years, makes it possible to successfully solve image compression problems using a new method.

7. Lack of JPEG2000 support in browsers. To view such images, you need to download a fairly large additional module (1.2 MB).

8. Lack of free software for saving images in the new format.

"MakTsentr"

Apple iPad Pro 2017

iPad Pro 2017, Pencil

Conclusion: Although the new iPad Pro tablet can compete with laptops in terms of performance, it will not yet be possible to completely replace workstations with tablets in the publishing industry. However, the emergence of full-featured applications for creating and processing images allows designers, illustrators and photographers to now make their main work iPad tool Pro with Apple Pencil. The main disadvantages of the tablet are traditionally high price and still insufficient attention to it from application developers.


The JPG format is most often used when working with images in everyday life. Typically, users try to save the picture in the highest available quality so that it looks clearer. This is good when the image is stored on the computer's hard drive.

If JPG has to be uploaded into documents or on different sites, then you have to neglect the quality a little in order to ensure that the picture turns out to be the right size.

Let's look at the best and fastest ways to reduce the size of an image so that you can compress a file in a few minutes without waiting for long times to download and convert from one format to another.

Method 1: Adobe Photoshop

The most popular image editor is Adobe's product, Photoshop. With its help you can produce a large number of various manipulations on images. But we will try to quickly reduce the weight of the JPG file by changing the resolution.

In addition to reducing the resolution, Photoshop also offers a feature called image quality reduction, which is a slightly more efficient way to compress a JPG document.

This option is no less effective than the first, but is slightly faster. In general, it is much better to combine the first two methods, then the image will be reduced not by two or three times, but by four or five, which can be very useful. The main thing is to remember that when the resolution is reduced, the quality of the image deteriorates greatly, so you need to compress it wisely.

Method 2: Light Image Resizer

A good program for quickly compressing JPG files is Image Resizer, which not only has a nice and friendly interface, but also gives tips on how to use the program. However, there is one downside to the application: only a trial version is available for free, which allows you to change only 100 images.


The method is quite convenient, since the program does everything you need and even a little more.

Method 3: Riot

Another program that is considered by many users to be very convenient and easy to use is Riot. Indeed, its interface is very clear and simple.


The program is one of the fastest, so if it is already installed on your computer, then it is better to use it to compress the image, since it is also one of the few programs that does not greatly spoil the quality of the original image.

Method 4: Microsoft Image Manager

Probably everyone remembers the Image Manager that came with the package office programs up to 2010. In version Microsoft Office In 2013, this program no longer existed, which is why many users were very upset. Now you can download it absolutely free, which is good news.


This is how you can quickly compress a JPG file using a fairly simple, but very convenient program from Microsoft.

Method 5: Paint

If you need to compress an image quickly, and the ability to download additional programs no, you'll have to use it preinstalled program on Windows - Paint. Using it, you can reduce the size of the picture, which will reduce its weight.

Use to reduce image weight Paint program It’s worth it only in the most extreme cases, since even after the same banal compression through Photoshop, the picture remains clearer and more pleasing to look at than after editing in Paint.

These are the convenient and quick ways to compress a JPG file that any user can use whenever they need it. If you know any other useful programs To reduce the size of images, write about them in the comments.

In the current age of mobile technology, optimization of images in PNG and JPG, JPEG formats has become relevant again, as it was relevant in those days when the Internet was just entering our lives and was universally slow and dial-up. Mobile Internet, of course, is not entirely correct to compare with dial-up, but in places where the connection is poor, the access speed is quite low. And even in those days, the user had nowhere to go, and had to wait for the page to load. Now the Internet has grown, there is a large selection of sites. The user became capricious and impatient, and the average page load time decreased greatly. It’s easier for the user to find another faster site.
Yes, and search giants like Google or Yandex began to pay attention to how quickly sites load, giving preference in the search results to those that are faster. The weight of the page also plays an important role in this, which, in turn, strongly depends on the weight of the images located on it. It's pretty obvious that having compact, compressed images is beneficial to everyone. Therefore, here I want to talk about how to prepare your PNG and JPG, JPEG files for uploading to hosting.

Basic image optimization

This involves trimming unnecessary fields, reducing color depth, removing comments and saving the image in a suitable format. To do this, you can use Adobe Photoshop, or, if you don't have it, MS Paint or GIMP.
Even basic cropping of the image will reduce its weight quite well.

How to make an image smaller in MS Paint

Using MS Paint as an example, I’ll show you how to reduce an image to the required size.
Let's take for example the NGINX logo and its nginx.png image measuring 2000x417 pixels, which needs to be cropped to 1024 in width, because This is the width of the page layout, and there is no point in doing more.

The output is an image that has undergone minimal basic optimization. It's time to move on to compressing her weight.

File Optimizer for PNG and JPG,JPEG compression

The simplest and quick way achieve optimal image compression without loss of quality - use File program Optimizer

Official website and program description :

Download File Optimizer you can with

Description . It is an effective optimizer not only for images, but also for .pdf, .docx, txt and other text, audio and video files, as well as archives. Full list supported extensions can be found at official page project.
Here are some of the utilities used in the work: AdvanceCOMP, APNG Optimizer, CSSTidy, DeflOpt, defluff, Gifsicle, Ghostcript, jhead, jpegoptim, jpegtran, Leanify, mozjpeg, MP3packer, mp4v2, OptiPNG, PngOptimizer, PNGOUT, pngquant, pngrewrite, pngwolf, TruePNG, tidy-html5, ZLib, zRecompress. I think even this partial list is quite impressive.

Installing and using File Optimizer

First download latest version programs either in the form of an installer or an archive with files. By the way, the archive has a version for 32-bit and 64-bit versions of Windows.

The interface is quite simple and intuitive.
Doesn't need any settings, but you can customize some formats for yourself using the Options button...
Usage . You either drag and drop the required files and even folders (directories) into the program window, or select the ones you need through the Add files... menu.
To optimize files, click Optimize all files

The optimized files will replace the source files, and the category hierarchy will also be preserved. Opposite each file, statistics will be shown, how much the optimized version weighs as a percentage of the original file size.
After completing the work, statistics on the number of processed files will be displayed below in the status line, as well as how much was saved.

In my opinion, File Optimizer does its job very well.
The only negative is that if the list of files is large, you can wait a long time for results, but it’s worth it.

If you are interested in details of optimization methods that can be configured in your own way, then we will talk about setting up and using utilities for image compression

Compress PNG without losing quality

Let's look at 3 programs for PNG optimization:

  • Adobe Photoshop
  • OptiPNG
  • PNGOUT

Let's compare them in terms of image compression quality. We will compress nginx.png from the previous section. The original weight is 27.5 KB.

Compress PNG using Adobe Photoshop

The first one on the list is Photoshop, which is well known to everyone. A multifunctional processor for a designer that can do almost everything, including compressing images.
Open in Photoshop File-Save for Web or use a combination Alt+Shift+Ctrl+S

As a result, we get 22.7 KB, i.e. shrank by 17.5%

Unfortunately, most graphics programs are unable to unlock the full potential of the algorithms used to compress PNGs. The main reason is that to determine the optimal compression strategy, they use heuristic algorithms that allow them to estimate the effectiveness of certain parameters without performing compression, which, as a result, produces a large percentage of errors. Therefore, to compress PNG we use utilities specially created for this purpose, namely OptiPNG and PNGOUT.

Using OptiPNG to Compress PNG

How to install and use OptiPNG

Downloaded the .exe, uploaded it to C:\Windows, took the desired PNG file, and put it in some folder. Now, using FAR Manager or another file manager with console support, go to this folder and enter the command into the console

Optipng -o7 nginx.png

The command forces you to compress the PNG in the folder. Later we’ll look at a simple option on how to do compression in one click.
But first, let's take a look at the result.

18.8 KB, i.e. shrank by 31.6%, almost a third. Not bad at all, isn't it? Photoshop turned out much worse.

Using PNGOUT to Compress PNG

How to install and use PNGOUT

Everything is exactly the same as for OptiPNG. Download PNGOUT.exe, drop it into C:\Windows, open in file manager, For example, Far Manager folder with PNG, and on the command line write

Pngout nginx.png

The result is below

The result is 23.4 KB, i.e. managed to compress by 15%. Very good.

In general, I’ll say right away that I had different results with different files, in some places PNGOUT worked more efficiently, in others OptiPNG, so I advise you to run the images one by one through both utilities.

How to quickly compress PNG in OptiPNG and PNGOUT

Create a png.reg file and write the registry data there

Windows Registry Editor Version 5.00 @="Run OptiPNG on Folder" @="cmd.exe /c \"TITLE Running OptiPNG on %1 && FOR /r \"%1\" %%f IN (*.png) DO optipng -o7 \"%%f\" \"" @="Run PNGOUT on Folder" @="cmd.exe /c \"TITLE Running PNGOUT on %1 && FOR /r \"%1\" %%f IN (*.png) DO pngout \"%%f\" \""

Then you run this file and write the data to the Windows registry.
Now, when you click on a folder with PNG files that need to be compressed, select the commands you need, compression will occur automatically for all images at once.

To remove everything from the context menu, write the following code into png.reg and run it

Windows Registry Editor Version 5.00 [-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\OptiPNG] [-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\OptiPNG\command] [-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\PNGOUT] [ -HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\PNGOUT\command]

JPG, JPEG compression without quality loss

To optimize JPG, JPEG, by analogy with PNG, there are utilities: jpegtran and jpegoptim. Of course, you can use Photoshop, but for JPG and JPEG compression I highly recommend using them.

How to install, configure and use jpegtran

jpegtran - powerful utility, which allows you to perform both simple JPG compression without loss of quality, as well as compression with a certain level of anti-aliasing, and even conversion to Progressive JPEG.
You can download jpegtran here http://jpegclub.org/jpegtran/ (look for and download jpegtran.exe).

How to compress JPG, JPEG using jpegtran

Upload jpegtran.exe to C:\Windows
Then open it in Far manager folder With desired JPEG and in the console enter

Jpegtran -copy none -optimize -outfile min.1.jpg 1.jpg # Basic optimization 1.jpg # -copy none removes metadata from JPG # -optimize optimizes the image

Progressive JPG, JPEG

This is a type of JPG that, when the page loads, first shows the general outline, then loads and brings the image quality to maximum. Very convenient for slow mobile internet, and therefore it must be used.

Jpegtran -progressive -outfile 1.jpg 1.jpg # Transforms the 1.jpg format to Progressive

How to check if an image is a Progressive JPEG

Advanced features of jpegtran

Here are all possible options for using jpegtran

Jpegtran --help usage: jpegtran inputfile outputfile Switches (names may be abbreviated): -copy none Copy no extra markers from source file -copy comments Copy only comment markers (default) -copy all Copy all extra markers -optimize Optimize Huffman table ( smaller file, but slow compression) -progressive Create progressive JPEG file Switches for modifying the image: -crop WxH+X+Y Crop to a rectangular subarea -flip Mirror image (left-right or top-bottom) -grayscale Reduce to grayscale ( omit color data) -perfect Fail if there is non-transformable edge blocks -rotate Rotate image (degrees clockwise) -scale M/N Scale output image by fraction M/N, eg, 1/8 -transpose Transpose image -transverse Transverse transpose image -trim Drop non-transformable edge blocks -wipe WxH+X+Y Wipe (gray out) a rectangular subarea Switches for advanced users: -arithmetic Use arithmetic coding -restart N Set restart interval in rows, or in blocks with B -maxmemory N Maximum memory to use (in kbytes) -outfile name Specify name for output file -verbose or -debug Emit debug output Switches for wizards: -scans file Create multi-scan JPEG per script file

How to quickly automatically compress JPEG using jpegtran in Windows

You won't be able to compress via the context menu due to the way the utility works, however, you can set up compression of multiple JPEGs at once automatically.
To do this, we need to create a file with the extension .bat (to help) and write it there

Cd/d. for %%j in (*.jpg) do call:sheensay "%%~nxj" "%%~nj.jpg" goto:eof:sheensay jpegtran -copy none -optimize -progressive "%~1" "%~2 "

How to install, configure and use jpegoptim

How to compress JPG, JPEG using jpegoptim

Upload jpegoptim.exe to C:\Windows. Then open the folder with JPG images with using Far Manager and enter into the console

Jpegoptim *.jpg --strip-all --all-progressive

How to optimize several JPGs, JPEGs at once using jpegoptim

Unlike jpegtran, the jpegoptim utility allows you to work with it quite well from the context menu.
Let's create a file jpegoptim.reg, for example, using Far Manager, and write there

Windows Registry Editor Version 5.00 @="Run jpegoptim on Folder" @="cmd.exe /c \"TITLE Running jpegoptim on %1 && FOR /r \"%1\" %%f IN (*.jpg) DO jpegoptim *.jpg --strip-all --all-progressive \"%%f\" \""

We launched it and entered the data into the registry. Now you can compress multiple JPEG files using the context menu, just add required images into one folder, RMB and “Run jpegoptim on Folder”.

If you want to remove jpegoptim from the registry and context menu, write jpegoptim.reg

Windows Registry Editor Version 5.00 [-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\jpegoptim] [-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\jpegoptim\command]

Save, run, make changes to the registry.

How well do jpegtran and jpegoptim compress jpg, jpeg

Let's move on to the tests. Take, for example, the caching.jpg file. In the original it weighs 29.5 KB

Jpegtran tests for JPG, JPEG compression quality

jpegtran -copy none -optimize -progressive caching.jpg caching.jpg

The output was 29.1 KB, compression saved 1.36%

Jpegoptim tests for JPG, JPEG compression quality

jpegoptim caching.jpg --strip-all

This is not visible in Windows Explorer; the compression was several hundred bytes.

Well, original file was well prepared, so the compression had no noticeable effect, but when you process your unoptimized images, you will sometimes be surprised at how much size savings you can make.

How to set up png and jpg, jpeg compression automatically

If you have read to this section, but are still dissatisfied with the options offered, I suggest you assemble a portable harvester yourself - a service for compressing pictures, photos, images that will work as you need right on your desktop.

Must be pre-installed jpegtran, jpegoptim, optipng, pngout Yu
Installation instructions are above.

So, for this we need to properly assemble the folder architecture. Let's say you have an images folder with its own hierarchy of subfolders with PNG and JPG that you need to process.
Create a folder optimus, put the images folder with all its subfolders and files into it.
Open , open optimus in it, create a go.bat file there and write it there

@ECHO OFF CLS SetLocal EnableExtensions EnableDelayedExpansion set home_path=%~dp0:: Name of the folder in which the raw images are located set folder=images echo Processing *.JPG files via jpegtran:: Create a folder in which the compressed jpg will be stored. In our case, this is jpeg_images xcopy /y /t /c /i "%folder%" "jpg_%folder%" :: For each.jpg we optimize with using jpegtran. Output.jpg will be written to jpeg_images for /r %folder% %%a in (*.jpg) do (set fn=%%a& jpegtran -copy none -optimize -progressive -outfile %home_path%jpg_!fn:%~dp0 =! %home_path%!fn:%~dp0=!) echo Processing of *.JPG files via jpegtran is completed:: We indicate that the run should now be carried out in a new folder jpeg_images set folder = jpg_%folder% echo Processing of *.JPG files via jpegoptim for /r %folder% %%a in (*.jpg) do (set fn=%%a& jpegoptim %%~a --strip-all) echo Processing of *.JPG files via jpegoptim completed echo Processing of *.PNG files via optipng xcopy /y /t /c /i "%folder%" "png_%folder%" for /r %folder% %%a in (*.png) do (set fn=%%a& optipng -o7 %% ~a -out %home_path%png_!fn:%~dp0=!) echo Processing *.PNG files via optipng completed set folder=png_%folder% echo Processing *.PNG files via pngout for /r %folder% %%a in (*.png) do (set fn=%%a& pngout %%~a) echo Processing of *.PNG files via pngout completed pause

The code is commented out in important parts. In fact, nothing complicated, you can figure it out if you need it.

Now save go.bat and run it.

If there are a lot of files, image compression will take some time. Wait until the console notifies you that the process has ended.

Compression takes place by separating JPG files separately, which are now located in jpg_images, and PNG files separately, which are located in png_images.

If you need to change quality or other parameters, see the description of the utilities above and change the code to suit your needs.

How to Optimize and Compress GIF

Finally

In this article, I tried to cover as fully as possible the methods of optimizing PNG and JPG. If you have any questions or additions, write in the comments, we’ll discuss

The main thing is to indicate the image on your computer or phone, specify the quality from 1 to 100, and click OK at the bottom of the page. The rest of the settings are set to default. How more indicated " quality» in settings (80-100), themes the size will be larger file. And vice versa, lower quality(50-75) will give smaller size JPEG file. If necessary, you can find out the level of quality (compression) with which the jpeg file was created.

If, after compression, the size of the jpeg file has become, on the contrary, larger than the original, then you need to lower the quality level from 80 to a lower number, for example, set 60. The sizes in pixels and megabytes before and after compression can be seen after processing or pressing the OK button. If, at a quality level of 40-50, the size is still larger than the original, then there is no point in compressing the image - it was already well compressed. You can only try to remove the metadata embedded in the jpg file or remove exif + make the jpg progressive without losing quality.

In the settings, you can select the type of subsampling (decimation), which allows you to achieve greater compression of the jpg file with minimal losses. Subsampling 1x1 gives the best image quality, bright color transitions are preserved, mainly suitable for high-quality previews or small preview images. 2x1 subsampling is the most common method, used in almost all digital cameras, compression of sharp color transitions occurs horizontally, allows you to achieve smaller size file without much loss, great for large images. 1x2- the same as 2x1, but only the averaging of sharp color transitions will be vertical. Subsampling 2x2 averages sharp color transitions horizontally and vertically, allows you to achieve the smallest file size, and is suitable for blurry pictures.

The original image is not changed in any way. You will be provided with another processed image in jpg format.

1) Specify an image in BMP, GIF, JPEG, PNG, TIFF format:

2) JPG file compression options
Reduce size in megapixels: reduction disabled reduce by 10% reduce by 20% reduce by 30% reduce by 40% reduce by 50% reduce by 60% reduce by 80% make no more than 0.5 MP (≈943x530) make no more than 1 MP (≈1366x768) make no more than 2 MP (≈1880x1060) make no more than 3 MP (≈2300x1300) make no more than 5 MP (≈2980x1670) make no more than 10 MP (≈4220x2370) make no more than 20 MP (≈5960x3350)
(Reducing the size by 20-30% in pixels or megapixels works well to reduce file size) Subsampling: 1x1 (best quality) 2x1 (medium quality) 1x2 (medium quality) 2x2 (low quality) Do not change (Thinning, averaging of sharp color transitions) Standard JPEG Progressive JPEG
(A progressive jpeg file almost always takes up 2-3% less space than a regular jpeg file with the same quality) Copy EXIF ​​and other metadata? Yes No
(“No” may further reduce the file size, but all additional information listed will be erased) Quality (from 1 to 100) (The main parameter, the lower the quality, the smaller the JPEG file size will be)


Processing usually lasts 0.5-20 seconds.

The photographs of "Red Pepper After the Rain" indicate the level JPEG quality for comparison:

The dimensions of this jpg image depending on the quality level (Q is quality, KB is the size in kilobytes):
Q 10 = 2 KB; Q 15 = 2.7 KB; Q 30 = 4.3 KB; Q 50 = 5.9 KB; Q 60 = 6.7 KB; Q 70 = 7.9 KB; Q 80 = 9.8 KB; Q 90 = 14.1 KB; Q 100 = 46.5 KB.

From the above examples we can conclude that the best size-quality ratio can be a quality level from 75 to 95. And in order for the picture to occupy the smallest size and at the same time be more or less normal, a quality of 60-70 is suitable. If quality does not matter, but you need a small file size, then a quality percentage of 30 to 50 is suitable.

Please note that the file size of a progressive JPEG image is usually 2-3% smaller than a standard one with the same image quality, and it will also open beautifully when loaded into an Internet browser, as is usually done in films! An example of a standard and progressive JPEG image can be viewed.

Pictures began to take up too much space and they simply cannot be sent via e-mail due to restrictions postal services? — In this article we will look at how to reduce the size of a JPG file as efficiently as possible and with minimal loss in source quality. Quite a lot has already been written on this topic on the Internet, but some use expensive programs, while others ignore the undisputed leaders in this niche.

I don’t quite understand the desire of some storytellers who force you to install monstrous Photoshop with an abundance of various plugins and filters to solve such an elementary task. You can do a simple cropping of the image and try to shrink it in size standard means Windows - Paint for example. Of course, we will lose quality with it, but what prevents us from considering other methods? - You will have plenty to choose from.

I would like to start with a small explanation about image resolution and its size - they do not always grow proportionally. Size different pictures at the same resolution it can differ significantly, but if we reduce the resolution of a very specific file, then its size is guaranteed to decrease in the end.

Lowering the resolution is not the best idea when it comes to image compression, but it does have its place in life under certain conditions. For example, send a photo to a friend or friend by email - on the monitor screen the difference will be almost invisible (with reasonable reduction of course), but for printing on large formats such a picture is no longer suitable - file resolution is very critical there.

But this is not the only way to compress a picture - we can use compression algorithms and remove meta tags from photos to reduce their size as much as possible. Surely many have noticed that VKontakte often marks the place on the map where the photo was taken. Your JPG file may contain information about GPS coordinates, camera models, shooting date, and other information that is useful for regular picture just not needed. Just by compressing the image and deleting this information, we can make our JPG file lose weight significantly.

Resizing JPG Files Using Paint

To adjust the resolution of a JPG file, we don’t necessarily need to install various programs (a stone in the garden for those who recommend installing Photoshop to compress images) - everything is already in standard applications from Windows, I think everyone is familiar with Paint.

We need to open the image in it and go through all the points in order, as indicated in the picture below. In the window that appears, you can safely experiment (change as a percentage or set fixed dimensions in pixels), just make sure that there is a checkmark next to “Maintain proportions” - otherwise you may end up with an image that is too stretched or flattened. To send by email, so that even in reality large monitor everything looked good, 1080 pixels horizontally will be enough (the image below, by the way, is approximately 730 pixels wide)

Unfortunately, Paint does not know how to compress images in the usual sense; it can only reduce the resolution of the JPG file, which is not always suitable. Here we can no longer do without third-party programs - we will consider free options which are as easy as possible to use.

By the way, to open a picture in Paint, just right-click on it and select “Edit”, the image will automatically open in the editor.

FileOptimizer - Remove unnecessary things from the photo

FiileOptimizer - This is a whole combine that can easily compress all your files on your computer in a couple of clicks. It can compress not only one file, but also an entire folder.

Agree that compressing files one at a time can take quite a lot of time and will quickly become annoying if you need to reduce more than a dozen photos. And then you dropped the folder and you can drink tea with bergamot.

It’s clear that we will lose quality, but with standard settings FileOptimizer pushes the limits of size and quality - most likely you won’t see the difference, but in fact it will be present. If desired, you can make more subtle settings (and the program can compress not only JPG, but also a lot of other formats) and set the required compression level.

Just for fun, I stole it from torrents small selection desktop wallpaper to estimate how much weight the images will lose after processing with FileOptimizer.

I dropped the entire folder into the program, clicked “Optimize all files” and left the program running. Unfortunately, I did not measure how long this process lasted, and for you it will depend on the performance of the processor installed in your system.

As you can see, we've made some progress in compression. Albeit a little, but the file size has changed downward - isn’t that what we wanted? For maximum effect you need to use complex measures: reduce the resolution in FileOptimizer - the output will be the most compressed file.

Since the program is free, I recommend that you download it only from the official website; by the way, there is a version that does not require installation - this is exactly the option I used in the current review.

How to reduce JPG file size online - my choice

If it were me, it would be a crime to ignore the best online service to resize JPG files (there is support for PNG compression). All pictures on this site are compressed through this service. To get started, simply follow the link:

There are some restrictions here, for example, no more than 20 files can be processed at a time and their size should not exceed 5 megabytes. You can simply drag the images into the browser window and wait for processing to complete. A test file with an image of my desktop, saved via Paint, was able to be reduced in size by 2 times without any visible loss in quality - I think this is a very decent result.

The resulting image can be downloaded to your computer or sent to the cloud on account DropBox.

There is also a Photoshop plugin from TinyJPG for compressing images on your computer. However, like all good things, it costs money, just like PhotoShop itself, by the way.

Conclusions about JPG file compression

Of course, there are many more ways to reduce the size of a JPG file. The article could have been called “20 Best Ways to Reduce JPG size file” and cover this topic in as much detail as possible. However, I don’t see the point in this - I described the options that I use myself.

P.S. Now you know how to reduce the size of a JPG file - there are 3 effective and simple ways. Until recently, I didn’t trust third-party resources and was always looking for computer programs to solve specific problems, but after trying tinyjpg I reconsidered my views and approach. I hope you also enjoy using it online tools in your work, and you will allow them to save treasured kilobytes of space.