How reduce picture file size

There are several ways to reduce a picture file size. For each of the formats PNG, JPG or GIF, the methods and tools for optimization may differ. Next, we will examine the differences and different ways of reducing weight, for example how to resize the image in paint without losing quality or the correct saving of images in Adobe Photoshop.


Why do you need to optimize your images

In the age of mobile technology the optimization of images to PNG and JPG,JPEG became topical again, as it was relevant in those days, when the Internet came into our lives and was commonly slow and dialplan. Of course, mobile internet is not correct to compare with dial-up, but places where is a bad connection, the access speed is quite small too. And in those times the user had nowhere to go, and had to wait for a page to load. Now the Internet has grown, we have large variety of websites. The user became capricious and impatient, and the average of waiting time for page loading greatly reduced. For the user is much easier to find another more speedy website.

The search giants like Google started to pay attention to how fast websites are loading. They are giving preference for the results which are more fast. Not the last place in this takes weight of the page, which is in turn, strongly depends on the weight of images disposed thereon. It is quite obvious to have a compact and compressed images is beneficial for all. So here I want to talk about how to prepare your PNG, JPG, JPEG files to fill in the web hosting.

Either you just want to compress the photos to save space on your hard drive.

Basic image optimization

This means cutting unnecessary fields, reducing the color depth, deleting comments and saving the image in a suitable format. You can use Adobe Photoshop for this, but if you don't have it, you can make use of MS Paint or GIMP.

Even basic cropping images a good idea to reduce it’s weight.

How to reduce an image in MS Paint

I will show by an example of MS Paint: how to reduce the image to the the necessary sizes.

For example we will take the logo with NGINX and picture nginx.png which has a size 2000×417 pixels and need to be cropped across the width up to 1024, because this is the width of the layout page, and do it longer is make no sense.

1.Open Paint (start – Run – Enter  "mspaint") 

open MS paint

2. Loading nginx.png;  looking for the "resize"; after that opens a window with percentages and pixels; you need to turn it on pixels and set the necessary size, in our case we enter the width - 1024.

size change ms paint

At the output you get an image that passed a minimal basic optimization. It's time to move on to the compression its weight.

File Optimizer to compress PNG and JPG,JPEG

The easiest and quickest way to achieve an optimal compression without losing image quality - use the program File Optimizer

Official site and a description of the program:

Download File Optimizer, you can from

Description. An effective optimizer is not only for images but also for .pdf, .docx, txt and other text, audio and video files, and also archives. Full list of supported extensions you will find on the official page of the project.

Here are some of tools which 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 an incomplete list is quite impressive.

The installing and usage of File Optimizer

First of all, you need to download the latest version of the programm either as an installer or archive files. By the way, the archive has the version for 32-bit and 64-bit versions of Windows.

File optimizer

The interface is quite simple and intuitive.

The programm does not require any adjustment, but you may also need some formats to adjust under yourself with the button Options...

Using. You can drag and drop the necessary files and even folders (catalogs) to the program window, or select via menu Add files...

To optimize files you need to click  Optimize all files

File optimizer interface

Optimized files will replace the source files, category hierarchy are also will be saved. Beside each file will be shown the statistics as a percentage of the original size of the file weigh to optimized version.

After completing the work, at the bottom in the status bar will display statistics oа the number of files have been processed, and as well how much space succeeded to save.

In my opinion, File Optimize performs its work in very high quality.

The only disadvantage, if the file list is large, can be a long wait for the results, but it's worth it.

If you are interested in the details of the optimization techniques that you can set up on your own way, then we will talk about configuration and usage of tools for image compression.

The compression of PNG without loss of quality

Let us consider the 3 programs for PNG optimization:

  • Adobe Photoshop
  • OptiPNG

Compare their pictures compression quality. Compress will nginx.png from the previous section. The weight of the original is 27.5 KB.

nginx original

Compression of PNG by using Adobe Photoshop

First on the list — a well-known photoshop. Multi-processor for the designer, which knows almost everything, including compress images.

In the photoshop we open a File-Save for Web or use the key combination Alt+Shift+Ctrl+S

photoshop save for web

The result is 22.7 KB, it means the file has been compressed to 17.5%

nginx after photoshop

Unfortunately, most graphics programs are not able to unlock the full potential of the algorithms used for PNG compression. The main reason is to determine the optimal strategy of compression which they use heuristic algorithms, which allows without a compression to estimate efficiency of these or those parameters that in effect, gives a large percentage of errors. So for PNG compression we use specially created for this utility, named OptiPNG and PNGOUT.

Using OptiPNG to compress PNG

OptiPNG is a software application designed specifically for the compression of PNG images. You can download it here

How to install and use OptiPNG

You need to download .exe, poured it into C:\Windows took a nessesary PNG file, put it in some folder. Now, using FAR Manager or other file Manager with support for console, you need to go to the folder and enter such command in the console:

optipng -o7 nginx.png

The command makes compress PNG folder. Later, consider a simple version of how to do the compression in one click.

But first, let's look at the result.

nginx after optipng

18,8 KB, it means that file was squeezed on 31.6%, almost the third part of  it. Very nice, isn't it? The photoshop turned out much worse.

Using PNGOUT to compress the PNG

PNGOUT - utility, as well as the previous one, is designed to compress PNG. You can download it here

How to install and use PNGOUT

Everything is exactly the same as for OptiPNG. Download PNGOUT.exe? then throw it in C:\Windows, afteк you need to open it in the file Manager, for example, Far Manager folder with PNG, and in the command prompt write

pngout nginx.png

nginx after pngout

The result is a 23.4 KB, it means that file was squeezed 15%. Very good.

In General, I have to say, I had different results with different files, somewhere PNGOUT worked better somewhere OptiPNG, so I suggest you to drive away the image in turn through both utilities.

How quickly compress PNG OptiPNG and PNGOUT

Create a png file.reg and write the data back to registry

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 run this file and write information to the Windows registry.

Now when you click on the folder with the PNG files that you want to compress, select the appropriate command, compression will happen automatically for all images at once.

run from windows

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

Windows Registry Editor Version 5.00

Compression JPG, JPEG without losing quality

To optimize JPG, JPEG, by analogy with the PNG are there any tools: jpegtran and jpegoptim. Of course, you can use photoshop, however, to compress JPG, JPEG, I strongly recommend to use them.

How to install, configure and use jpegtran

Jpegtran is a powerful tool that allows you to perform as just the JPG compression without loss of quality and compression with a certain level of smoothing, and even conversion to Progressive JPEG.

Download jpegtran here (looking and shake jpegtran.exe).

How to compress JPG, JPEG with jpegtran

Add jpegtran.exe in C:\Windows

Then open in Far Manager the folder with the 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

How to compress JPEG with a certain quality level

This method reduces the image quality. But it sometimes imperceptibly, but the savings amount can be quite substantial. Experiment.

jpegtran -quality 80 -copy none -optimize -outfile min.80.1.jpg 1.jpg

# -quality 80 compresses JPEG with a compression quality of 80
# Possible quality values from 5 to 95
# The smaller the number, the stronger the compression

Progressive JPG, JPEG

This is the type of JPG that when the page loads first shows the overall outline, then loads in addition and brings the picture quality up to maximum. Very handy for slow mobile Internet, and because you want to use.

jpegtran -progressive -outfile 1.jpg 1.jpg

# Transforms the format 1.jpg into Progressive

How fast on the machine to compress the JPEG with jpegtran

Via the context menu compress will not work because of the nature of utility work, however, adjust the JPEG compression of the set time on the machine.
For this we need to create a file with the extension .bat (Far Manager to help) and write down the

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

Next, place this file in the folder with the JPEG and start. Optimized images ready to use.

How to install, configure and use jpegoptim

Download the Windows version here

How to compress JPG, JPEG using jpegoptim

Pour jpegoptim.exe in C:\Windows. Then open a folder with JPG images, using Far Manager and enter in the console

jpegoptim *.jpg --strip-all

How to optimize multiple JPG, JPEG time using jpegoptim

Unlike jpegtran, jpegoptim utility is absolutely possible to work with it and from the context menu.

Create a file jpegoptim.reg, for example, by 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

Launched, contributed data to the registry. Now you can compress multiple JPEG files using the context menu, just put the desired image in the same folder, RMB and "Run jpegoptim on Folder".

how use hpegoptim

If you want to uninstall jpegoptim from the registry and the shortcut menu, record jpegoptim.reg

Windows Registry Editor Version 5.00

Save, start, make changes to the registry.

How well jpegtran and jpegoptim compress jpg, jpeg

Now for the tests. Take, for example, the file caching.jpg. In the original he weighs 29,5 KB

original image

Test jpegtran for JPG compression quality, JPEG

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

caching after jpegtran

The output was of 29.1 KB, compression saved 1,36%

Test jpegoptim for JPG compression quality, JPEG

jpegoptim caching.jpg --strip-all

caching jpegoptim

In Windows Explorer it is not visible, the compression amounted to several hundreds of bytes.

Well, the original file was well prepared, so the grip did not give a visible effect, but when you will handle your non-optimized images, sometimes you'll be surprised how well you can save in the amount.

How to set compress png and jpg, jpeg on the machine

f you read this section, but are still unhappy with the options offered, offer you to build a portable harvester — service resizing of pictures, photos, images that will work as you need right on your desktop.
So, for this we need to correctly assemble the architecture of folders. Let's say you have an images folder, it uploads folder with its hierarchy of subfolders with PNG and JPG, which you need to handle.
Create a folder optimus, it'll cast the images folder and all its subfolders and files.
Open Far Manager, in it optimus open, create there file go.bat and write in there

SetLocal EnableExtensions EnableDelayedExpansion
set home_path =% ~ dp0

:: The name of the folder that contains the raw images
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 jpegtran. The output .jpg will be recorded in 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 * .JPG files via jpegtran completed

:: Specify that the run should now be performed in a new folder jpeg_images
set folder = jpg_% folder%
echo Processing * .JPG files via jpegoptim
for / r% folder% %% a in (* .jpg) do (
set fn = %% a & jpegoptim %% ~ a --strip-all
echo Processing * .JPG files through jpegoptim completed

echo Processing * .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 * .PNG files through pngout completed

Code commented out in the important parts. In fact, nothing complicated, will understand if you need it.

Then save go.bat and run it. The compression is split JPG files separately, which will now be jpg_images, and PNG separately, which are located in png_images.

Quickly and efficiently.

If you want to change the quality or other parameters, see the description of the utilities above and modify to fit your needs.

How to optimize and compress GIF

Use File Optimizer. But remember, it is important to use GIF only for animated images. Instead, use PNG. Shimada PNG better than GIF, PNG it is possible to use a transparent substrate, no limitation of 256 colors in the palette.

 In conclusion

In this article I have tried maximized to cover the ways of optimizing PNG and JPG. And as always you can just use oue free online image compressor.