Author: Alex

How to increase the color (saturation) of images, how to make a photo warmer or colder

You have probably noticed that other people's photographs can look very beautiful: incredible colors and shades, the landscape seems to be from a postcard.

You might think that it's all about some very expensive camera, the outstanding talent of a photographer, or incomprehensible skills in photo processing. All this can take place, but in fact, you can turn an ordinary photo into a very juicy and bright one with just one slider in the photo editor.

For this post, I'll be using the free and open source GIMP image editor. But in fact, you can find a similar function in other paid and free programs. You can transform your photos in photo editors on mobile phones as well.

How to enhance the color of an image. How to make colors vibrant

In GIMP, go to Color → Hue-Saturation.

Here you will see only one “Scale” slider.

Moving to the right will make the colors more saturated.

Original image:

Image with high saturation:

Original image:

Image with high saturation:

Original image:

Image with high saturation:

Perhaps I do not know the measures (I set the saturation almost to the maximum), and the photos became too colorful. You can change the saturation according to your taste and artistic intent.

How to make a photo warmer or colder

A warmer photo has more yellowness, a colder photo has more blueness.

Changing the temperature of a photo also greatly changes its perception.

To change the temperature of a photo in GIMP, go to Color → Color Temperature.

Here you will see two sliders “Original temperature” and “Intended temperature”. experiment with both of them.

Original Image:

Image in warm colors:

Image in cold colors:

Changes in shadows and light

Let’s consider how to emphasize the shadows and light sources in the photo.

From the GIMP menu, go to Color → Shadows-Highlights.

Here you can increase or decrease the shadows in the photo, as well as increase or decrease the intensity of the light source.

For example, reducing the amount of light:

Original Image:

Look how expressive and even menacing the clouds have become:

In the following example, the amount of light is added:

Original Image:

And now the clouds have become shining like in a biblical parable:

Experiment with color!

I guess you agree that the simplest manipulations shown above with literally one settings slider can significantly change the impression of a photo. The pictures have become noticeably more spectacular, but at the same time they have not lost their realism.

The GIMP Preferences menu under Color has other settings you can try.

Pay special attention to “Brightness”, “Contrast”, “Exposure”. With them, you can change the impression of the photo.

How to prevent search engines from indexing only the main page of the site

To prevent search engines from indexing only the main page, while allowing indexing of all other pages, you can use several approaches, depending on the characteristics of a particular site.

1. Using the robots.txt file

If the main page has its own address (usually it is index.php, index.html, index.htm, main.html and so on), and while trying to open a link like w-e-b.site/ a website redirects to the main page, for example, to w-e-b.site/index.htm, then you can use the robots.txt file with something like the following content:

User-agent: *
Disallow: /index.php
Disallow: /index.html
Disallow: /index.htm
Disallow: /main.html

In fact, using an explicit name for the main page is the exception rather than the rule. So let's look at other options.

You can use the following approach:

  1. Deny site-wide access with the “Disallow” directive.
  2. Then allow the indexing of the entire site using the “Allow” directive, except for the main page.

Sample robots.txt file:

User-agent: *
Allow: ?p=
Disallow: /

The “Allow” directive must always come before “Disallow”. The “Allow” directive allows all pages with a URL like “?p=”, and the “Disallow” directive disables all pages. As a result, the following result is obtained: indexing of the entire site (including the main page) is prohibited, except for pages with an address like “?p=”.

Let's look at the result of checking two URLs:

  • https://suay.ru/ (main page) – indexing is prohibited
  • https://suay.ru/?p=790#6 (article page) – indexing allowed

In the screenshot, number 1 marks the contents of the robots.txt file, number 2 is the URL being checked, and number 3 is the result of the check.

2. Using the robots meta tag

If your site is separate files, then add the robots meta tag to the HTML code of the main page file:

<meta name="robots" content="noindex,nofollow>

3. With .htaccess and mod_rewrite

Using .htaccess and mod_rewrite, you can block access to a specific file as follows:

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} Google [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Yandex [NC]
RewriteRule (index.php)|(index.htm)|(index.html) - [F]

Please note that when you try to open a link like https://w-e-b.site/ (that is, without specifying the name of the main page), a specific file is still requested on the web server side, for example, index.php, index.htm or index. html. Therefore, this method of blocking access (and, accordingly, indexing) works even if the main page of your site opens without specifying a specific file name (index.php, index.html, index.htm, main.html, and so on), as is usually the case.

How to downgrade to a previous kernel version in Arch Linux. How to install and switch to linux-lts

New Linux kernels bring support for new hardware and new features. But sometimes the kernel causes problems: it is completely or partially incompatible with existing software, especially video drivers suffer from this, but this can also apply to any other software, for example, VirtualBox.

At the time of the release of the linux 5.9 kernel, NVIDIA drivers were partially incompatible with it, as a result, their important functionality was lost. Although the graphics card worked, but CUDA, OpenCL and probably other features are broken. Of course, this was fixed pretty quickly, but what about those who needed CUDA and OpenCL or other programs that were incompatible with the latest version of the Linux kernel at the time of the problem?

A very recent example, the linux 5.19 kernel at the time of writing is not compatible with the latest version of VirtualBox, which just doesn't work. The problem will be fixed in the near future, but what if you need running VirtualBox machines right now?

One option is to rollback to a previous version by installing it from the downloaded package cache. The method is not the most pleasant, since it will be necessary to prohibit updating the package, the version of which was rolled back, or even refuse to update the entire system.

This method is especially annoying when it comes to the linux kernel – you also need to do something with dependencies.

One of the easier options is to switch to the linux-lts kernel.

How to install linux-lts

LTS – stands for Long Time Support. Simply put, this is a Linux kernel and modules from one of the previous versions, which is rarely updated.

This kernel can be installed as a regular package, replacing the existing kernel. Depending on your computer configuration, you may need to install other *-lts packages, such as the nvidia-lts package, an NVIDIA video driver for the linux-lts kernel.

Also install linux-lts-headers.

All these packages can be installed with the command:

sudo pacman -S linux-lts linux-lts-headers nvidia-lts

Please note that it is not required to remove the old kernel and also the NVIDIA drivers (although you can do this if you wish).

How to switch to linux-lts kernel. Boot options update

In order to use the linux-lts kernel, you need to change the boot options.

Changing boot options is done differently depending on whether you are using GRUB or systemd-boot.

If you are unsure, see “How to check if a computer is using BIOS or UEFI; GRUB or systemd-boot bootloader; MBR or GPT partition table”.

Update boot options for systemd-boot

Open file /boot/loader/entries/arch.conf

sudo vim /boot/loader/entries/arch.conf

Or:

sudo gedit /boot/loader/entries/arch.conf

And replace the lines in it

linux   /vmlinuz-linux
initrd  /initramfs-linux.img

On the

linux   /vmlinuz-linux-lts
initrd  /initramfs-linux-lts.img

For example, the full content of my file was

title	BlackArch
linux   /vmlinuz-linux-lts
initrd  /initramfs-linux-lts.img
options	root=/dev/nvme0n1p2 rw

I commented out the lines that point to the normal kernel version and added the lines that point to linux-lts:

title	BlackArch
#linux	/vmlinuz-linux
#initrd	/initramfs-linux.img
linux   /vmlinuz-linux-lts
initrd  /initramfs-linux-lts.img
options	root=/dev/nvme0n1p2 rw

Then reboot and make sure you are using the LTS kernel version with the command:

uname -a

Update Boot Options for GRUB

Update your GRUB configuration:

sudo grub-mkconfig -o /boot/grub/grub.cfg

Then reboot and make sure you are using the LTS kernel version with the command:

uname -a

After the kernel has been improved and the problems that are bothering you are fixed, you can return to the latest version of the Linux kernel.

How good is 5G – review after real experience of use

How to connect to 5G network


How much talk about 5G, about new phones with 5G, about the assurances of mobile operators to start supporting 5G and increase the coverage of existing networks.

But how important is 5G? Is this really a breakthrough or a marketing ploy to force users to buy newer and more expensive phone models? It happens that new technologies advertised by marketers turn out to be hardly noticeable or simply invisible “by eye”. For example, a new generation of CPUs that either work faster, or work not faster, but better, or work even slower, but still somehow better – I think you roughly understand what I mean.

I am a real user of 5G mobile internet and in this post I want to share my opinion about 5G.

5G networks have appeared in my city, my phone supports 5G, so I decided to test this technology in normal use.

In fact, when talking about the Internet, including the mobile Internet, most users are primarily interested in only two characteristics:

  1. Transfer rate (bandwidth).
  2. Stability (reliability) of data transmission.

So I didn't invent any fancy tests, but just took measurements with Speedtest, and also used the Internet in my daily activities.

5G is a breakthrough in mobile Internet speeds!

Look at these screenshots:

Download speed 460 Mbps! If you are more accustomed to megabytes, then this is about 50-60 MB/s.

Data upload speed is about 30 Mbps!

Once again, mobile Internet at almost half a Gbps!

Not all users even have wired Internet at such speeds. That is, it is very fast.

Moreover, only router models that support the latest Wi-Fi standards are able to provide network connections at such speeds (in theory, in practice, speeds are much lower. For example, 802.11ac has speeds up to 1300 Mbps at 5 GHz plus up to 450 Mbps at 2.4 GHz.

I use my phone as a mobile hotspot through which my computer accesses the Internet. The Access Point must be enabled at 5 GHz, otherwise the Wi-Fi speed at 2.4 GHz may simply not be enough.

I made these measurements of the speed of accessing the Internet through a phone and a 5G network on a computer.

How stable is the Internet in 5G networks

To test how long the high speed of the Internet will last for long periods of time, I decided to check on torrents.

I got about half the speed compared to the measurements on Speedtest. However, I do not think that this is the limit. The fact is that the speed of downloading a torrent depends on the number of people involved in downloading and uploading a file (Seeds and Peers). But even relatively large files at such speeds are downloaded quite quickly. That is, at the beginning of the download there are few Seeds, so the speed is incomplete, in the future the number of Seeds increases, but the download of the file is coming to an end.

That is, I believe that even when downloading large files, 5G networks can consistently have high Internet speeds.

See also:

What you need to use 5G networks

You won't get any benefits from 5G if your phone doesn't support 5G networks. That is, first, you need a phone with 5G support.

To make sure your phone supports (or doesn't) go to Settings → Connections → Mobile networks → Network mode SIM.

If you do not see 5G there – then try clicking on the inscription “Network mode SIM” to see if there is a 5G mode.

If there is no 5G there, then most likely your phone cannot work with 5G mobile networks.

Of course, your mobile operator must deploy 5G mobile networks.

If both of these conditions are met, but your phone cannot connect to 5G networks, then this is possible for the following reasons (the list is not complete):

  1. You are out of range of 5G networks.
  2. You need to update your SIM card
  3. You need to enable 5G support in settings as shown above

You won't get any of the benefits of 5G if your carrier plan has a rate limit

Look at the following screenshot.

It is made by the proud owner of an annual tariff plan, which is unlimited (for the number of Gigabytes), but is limited to 10 Mbps.

That is, if you have chosen a tariff plan with a speed limit, then when you switch to 5G, you will not notice any difference. The Internet speed on your phone will be limited by the speed of your data plan.

How to enable saving videos in HEVC in Android to reduce file size

What is HEVC video

HEVC H.265 the new video format, which allows you to compress video files much stronger (almost 2 times compared to the old formats) without losing quality. It is important for 4K movies and high-definition video streaming.

Some mobile phones (for example, iPhone) already save videos in this format by default (although you can switch to the old format in the phone settings).

You can get the HEVC codecs for free through the Microsoft Store on Windows 11 and on Windows 10. You won't be able to find them in the Microsoft Store using the search feature. To get the free package, copy and paste the following code into your web browser's address bar, then press Enter:

ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq

This is not so important, because many video media players work fine with the HEVC H.265 format. And in order for this format to be able to play even the built-in Windows media player, it is enough to install the codec mentioned above.

That is, the HEVC format is well supported by operating systems and mobile phones.

Anyway, should I use HEVC?

HEVC video examples

So that you can evaluate the file sizes and the quality of the HEVC picture, I made a few very short videos for you.

They are of the same duration.

When switching to the HEVC format, the video size is almost halved (about 1.6-1.8 times less).

I deliberately did not upload videos to YouTube so that you can evaluate the original quality before processing and converting files.

You can download video files to your computer to test how well your operating system works with HEVC files.

This video uses the H264 - MPEG-4 AVC (part 10) (avc1) codec:

Download file: https://zawindows.ru/wp-content/uploads/2022/08/Pattaya-H264.mp4

Video specifications:

Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L5.2
Format settings                          : CABAC / 1 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 1 frame
Format settings, GOP                     : M=1, N=60
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 10 s 163 ms
Bit rate                                 : 73.0 Mb/s
Width                                    : 3 840 pixels
Height                                   : 2 160 pixels

And this video uses the MPEG-H Part2/HEVC (H.265) (hvc1) codec:

Download file: https://zawindows.ru/wp-content/uploads/2022/08/Pattaya-hevc.mp4

Video specifications:

Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main@L5.2@Main
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 10 s 496 ms
Bit rate                                 : 41.5 Mb/s
Width                                    : 3 840 pixels
Height                                   : 2 160 pixels

And the first surprise that you might encounter is that the video does not play at all, or the web browser offers to play it as an audio file.

You can download the file to your computer and make sure that it is still a video file.

If you have already read the article “How to enable saving photos in HEIC (HEIF) format in Android and whether it should be done”, then this problem should have been expected for you. New formats are good for everyone, except that web browsers have poor support for them.

Another video in H264:

Download file: https://zawindows.ru/wp-content/uploads/2022/08/Pattaya-beach-H264.mp4

Similar video in HEVC format (H.265):

Download file: https://zawindows.ru/wp-content/uploads/2022/08/Pattaya-beach-hevc.mp4

Does YouTube support HEVC format

Yes, I checked, when uploading a video in HEVC format, YouTube video hosting works fine with it, there are no restrictions or difficulties.

How to save video in HEVC in Android

If you still came to the conclusion that the HEVC format is interesting for you and you want to use it to significantly reduce the size of video files without changing the video quality, then the following shows how to enable saving captured videos on Android in the HEVC format (H.265 ) on the example of the Samsung Galaxy S21 Ultra phone.

Open the camera and switch to video recording.

Click the gear icon to go to the camera settings.

Go to the “Advanced recording options” section.

Find the “Reduce file size” option.

Turn on the slider.

The description of the option says that the Reduce file size option is designed to save space without sacrificing video quality. The results will be saved in HEVC format, which some apps and websites don’t support.

Ambient sound in Galaxy Buds2: an analogue of the transparency mode from Samsung

How to listen to ambient voices and sounds in Galaxy Buds2 without turning off the music

Apple's AirPods Pro have a feature called Transparency mode. Its essence is that instead of actively suppressing ambient sounds and noises, they are, on the contrary, transmitted to the user's ear. Thanks to this, you can hear the voice of the interlocutor without turning off the music, as well as hear what is happening around you when, for example, you are in public transport or walking down the street.

The function is at least interesting and many users find it very useful. But is it necessary to have an iPhone and AirPods Pro to have this feature?

In fact, many wireless headphones already support this feature, such as the Jabra Elite 75t and the Sony WF-1000XM4.

I want to talk about the transparency mode on Android.

I use headphones and a phone from Samsung, namely Galaxy Buds2 and Galaxy S21 Ultra.

In Galaxy Buds2, the analogue of the transparency mode is called “Ambient sound”.

For easy control of your Galaxy Buds2, install the Galaxy Wearable app. With this app, you can change Galaxy Buds2's touch action settings, select different modes, turn on Galaxy Buds2's headphone search function, and more.

By the way, updating the Galaxy Buds2 firmware is also done through the Galaxy Wearable app.

Galaxy Wearable has 3 options under Noise controls:

  • Active noise cancellation
  • Off
  • Ambient sound

It is the “Ambient sound” mode that enables amplification of the audibility of external sounds, such as the speech of people around and other noises.

When “Ambient sound” is enabled, a new setting "Ambient sound volume" will appear, you can choose from “Low”, “Medium”, “High”.

You don't have to launch the Galaxy Wearable app each time to change the Noise controls settings. You can also change these settings by touching the Galaxy Buds2.

A long touch on the Galaxy Buds2 means to switch the Noise controls to the opposite mode. For example, if “Active noise cancellation” is already selected, the “Ambient sound” mode will be enabled. If “Ambient sound” is already selected, “Active noise cancellation” will be enabled.

If both of these modes are disabled, then a long touch on the Galaxy Buds2 will first turn on “Active noise cancellation”, and a second long touch will turn on “Ambient sound”.

As with any feature that has to do with ergonomics and user habits, it takes getting used to Noise controls and its modes.

How to remove navigation bar buttons in Samsung Galaxy S22

The first Android phones had physical buttons at the bottom of the screen (there were 3 or 4 depending on the model). With these buttons, you could close the application or undo the last action, return to the main screen, or go to the list of recently opened applications.

Subsequently, these buttons became virtual, that is, part of the image displayed on the phone screen. But this did not stop them from taking up space on the surface of the phone.

The advantage of virtual buttons is that they can still be completely removed from the screen, as a result, the entire surface of the screen becomes a usable area, without the area constantly occupied by buttons.

Is it convenient to control swipe gestures on Android

The question may arise, how then to control the phone if there are no buttons? In this case, swipe gestures are used to control the phone.

In my case, I got used to gestures in a few days (although I used buttons for many years before that). Gestures are no more difficult to control than buttons.

But it cannot be said that there is absolutely no discomfort: when I pick up a phone with buttons, by inertia I try to control it with gestures. And only then, after making sure that nothing works, I notice the buttons.

There are no other inconveniences.

If you want to try switching to swipe gesture control, it's recommended that you try it out for at least a few days, as it's going to be weird at first anyway.

How to enable gesture control and remove buttons on Android

Start by opening your phone's settings menu. The easiest way to do this is to swipe down from the top of your phone's display and drag down the notification bar. From here, tap the gear icon in the top right corner.

Scroll down the menu and find the “Display” section.

Find the “Navigation bar” section and go to it.

Select “Swipe gestures”.

It is also recommended to enable the item “Show button to hide keyboard”.

This button is needed not so much to actually hide the keyboard, but to create a gap between the bottom edge of the screen and the keyboard. If it is not there, then it will not be easy to perform a gesture if there is a keyboard on the screen, since the phone will perceive touches not as a swipe gesture, but as input from the keyboard. As soon as there is a gap, the phone will correctly perceive both swipe gestures and keyboard input.

How to control swipe gestures in Android

In fact, the control is elementary, and there are only three gestures:

  1. Swiping from the right or left edge of the screen means Back, Cancel, Close App.
  2. Swiping up from the bottom of the screen means going to the main screen, similar to the Home button.
  3. Swiping up from the bottom of the screen without lifting your finger from the screen at the end of the gesture means to go to the list of recently opened programs.

The gesture from top to bottom opens the curtain, but the setting described in this manual does not affect it.

Analogue of Add-Computer in PowerShell 7

===========================================================

UPDATE:

Testing with PowerShell 7.3.0-preview.5 shows that Add-Computer is back!

Command

Get-Command -module Microsoft.PowerShell.Management

outputs the following:

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Add-Computer                                       1.0        Microsoft.PowerShell.Management
………………….
………………….

That is, Add-Computer is present, it is a function (not a cmdlet), the version is indicated as 1.0. The status of Add-Computer is not completely clear: is it a temporary hotfix or a gradual return of the cmdlet?

===========================================================

Add a computer to a domain or workgroup in PowerShell

The Add-Computer cmdlet joins a computer to a Windows Domain or to a Workgroup. The Add-Computer cmdlet adds the local computer or remote computers to a domain or workgroup, or moves them from one domain to another. It also creates a domain account if the computer is added to the domain without an account. You can use the parameters of this cmdlet to specify an organizational unit (OU) and domain controller or to perform an unsecure join.

An example of a command that adds the local computer to the domain and restarts the computer:

Add-Computer -DomainName Domain01 -LocalCredential Domain01\Administrator -Restart

The following command adds the local computer to the workgroup, or renames the workgroup (if the computer is already in a workgroup with a different name):

Add-Computer -WorkgroupName WORKGROUP-A

These commands work fine in PowerShell 5, which is built in by default in all versions of Windows up to Windows 11 and all server versions up to Windows Server 2022.

See also: How to check PowerShell version in Windows 11

Error “Add-Computer: The term 'Add-Computer' is not recognized as a name of a cmdlet, function, script file, or executable program.”

But in PowerShell 7, this command is missing:

Add-Computer
Add-Computer: The term 'Add-Computer' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Suggestion [4,General]: The most similar commands are: Add-Computer, Stop-Computer, Get-ADComputer, New-ADComputer, Set-ADComputer, Add-Content, Rename-Computer, Add-Member.

You can verify that the command named Add-Computer is indeed present in PowerShell 5, where it is placed in the Microsoft.PowerShell.Management module:

powershell
Get-Command -Module Microsoft.PowerShell.Management -Name *Computer* | Select Name

But Add-Computer is missing from PowerShell 7:

pwsh
Get-Command -Module Microsoft.PowerShell.Management -Name *Computer* | Select Name

You can count exactly how many commands are removed from the Management module when moving from PowerShell 5 to PowerShell 7:

powershell
Get-Command -Module Microsoft.PowerShell.Management | Measure-Object | select Count

pwsh
Get-Command -Module Microsoft.PowerShell.Management | Measure-Object | select Count

There were 89 command, 61 commands remained.

How to replace Add-Computer in PowerShell 7

One of the suggested alternatives seems to be the New-ADComputer cmdlet, but the documentation explicitly says that “This cmdlet does not join a computer to a domain”.

There is no information about where the Add-Computer cmdlet or what its alternative is in PowerShell.

One working solution, if you've already installed PowerShell 7, is to run the join Domain or Workgroup command in PowerShell 5. To do this, run the following sequence of commands:

powershell
Add-Computer -DomainName Domain01 -LocalCredential Domain01\Administrator -Restart

See also: How to install the latest PowerShell on Windows 11

How to modify images on the Linux command line

ImageMagick is a powerful program and library for creating and modifying images on the command line. This section will cover the commands and options that you can use to imitate a drawing with paints, pencil, charcoal, make an image black and white; rotate the image to an arbitrary angle or display the image horizontally or vertically; resize the image; add or reduce noise in the image; add a frame to the image; simulate 3D; add text with custom style and formatting; superimpose one image on another; apply other popular filters.

These examples are among the simplest cases of using ImageMagick on the command line to modify images, since most of them only require one option. More complex examples will be covered in the sections on creating new images and using ImageMagick scripts.

The “magick” utility is part of the ImageMagick package. For details on installing ImageMagick, including which dependencies you need to install to support the maximum number of formats, as well as a description of the command structure, examples of usage and all options, see the article: ImageMagick guide: installing, using, and troubleshooting.

Of course, you can do all the actions shown below in the image editor with a graphical user interface. Command line tools are especially effective when processing large numbers of images or when developing services.

The following image will be taken as the source:

Combining ImageMagick options and actions

One ImageMagick (magick) command can perform several actions at once. Moreover, if you use formats like JPEG, that is, those that compress images with loss of quality (lossy), then try to reduce the number of operations (the number of times JPG is compressed) and do all the actions at once (or use formats that save lossless images (e.g. PNG).

Most of the options discussed below can be combined with each other, as well as with the familiar -scale PIXELS and -quality QUALITY options.

For example:

magick IMAGE.jpg -scale 200 -paint 1 test.jpg

You can also combine the already considered image conversion with any options. That is, in one command you can modify the image and convert it to another format:

magick IMAGE.jpg -scale 200 -paint 1 test.png

How to extract an area of an image (cropping a picture)

To extract a region of an image use the option -extract WIDTHxHEIGHT+x0+y0

In this line:

  • WIDTH – the width of the area to be extracted
  • HEIGHT – the height of the area to be extracted
  • x0 – x coordinate of the upper left corner of the area to be extracted
  • y0 – y coordinate of the upper left corner of the area to be extracted

The -extract option must come before the image from which the region is being extracted!

After using this option (after the name of the file from which the region is extracted), specify the +repage option, which will override this option, otherwise it will be applied to all images processed in this command.

The following command extracts a 500×400 pixel area from the IMAGE.jpg file, which is located at a distance of 300 pixels from the left edge and 150 pixels from the top edge, and saves the resulting new image to the test21.jpg file:

magick -extract 500x400+300+150 IMAGE.jpg +repage test21.jpg

Instead of the -extract WIDTHxHEIGHT+x0+y0 option, you can use the format:

FILE[WIDTHxHEIGHT+x0+y0]

The following command is identical to the previous one:

magick 'IMAGE.jpg[500x400+300+150]' +repage test21.jpg

When processing a large number of photos, to save computer resources (primarily RAM), use Image cropping while reading.

How to apply an effect to an area of an image

By default, the options shown below change the entire image. If you want to change only a certain area of the image, then use the option -region WIDTHxHEIGHT+x0+y0

In this line:

  • WIDTH – the width of the area being modified
  • HEIGHT – the height of the area being modified
  • x0 – x coordinate of the upper left corner of the area being modified
  • y0 – y coordinate of the upper left corner of the area being modified

For example, in the following command, the -negate effect (see the description of this option below) will be applied only to the 500×400 pixel area of the IMAGE.jpg image, which is located at a distance of 300 pixels from the left edge and 150 pixels from the top edge, the resulting new image is saved in test21.jpg file:

magick IMAGE.jpg -region 500x400+300+150 -negate test21.jpg

How to imitate an oil painting

To make the photo look like a painting, use the -paint RADIUS option.

This option creates an imitation of an oil painting.

Each pixel is replaced by the most frequently occurring color in a circular neighborhood whose width is determined by the radius.

Command example:

magick IMAGE.jpg -paint 4 test1.jpg

Result:

How to imitate a charcoal drawing

To make the photo look like it was drawn with charcoal, use the -charcoal RADIUS option.

Command example:

magick IMAGE.jpg -charcoal 5 test2.jpg

Result:

How to mimic a pencil sketch

The -sketch GEOMETRY option creates a simulated pencil sketch.

Command example:

magick IMAGE.jpg -sketch 5 test3.jpg

Result:

This option has the following syntax options:

  • -sketch radius
  • -sketch radius{xsigma}+angle

The last version of the option creates a sketch with the specified radius, standard deviation (sigma) and angle. The specified angle is the angle at which the image is drawn. This is the direction people think the object is coming from.

How to make an image black and white

How to convert an image to black and white on the Linux command line? With the -monochrome option, you can convert an image to black and white.

Command example:

magick IMAGE.jpg -monochrome test4.jpg

Result:

How to create an image negative

With the -negate option, you can replace each pixel with its complementary color.

The red, green, and blue intensity of the image is inverted. White becomes black, yellow becomes blue, and so on. Use +negate to invert only the pixels in a grayscale image.

Command example:

magick IMAGE.jpg -negate test5.jpg

Result:

How to flip and flop images (vertical and horizontal image mirroring) on the Linux command line

To flip and flop an image horizontally or vertically, use the options:

  • -flip (image will be flipped upside down)
  • -flop (the image will be flopped, mirrored from left to right - just like in a mirror)

Command example:

magick IMAGE.jpg -flip test6.jpg

Result:

Command example:

magick IMAGE.jpg -flop test7.jpg

Result:

How to rotate an image on the Linux command line

To rotate an image, use the -rotate DEGREES option. Degrees can be set to either positive (for clockwise rotation) or negative (for counterclockwise rotation) values. For example:

magick IMAGE.jpg -rotate 30 test8.jpg
magick IMAGE.jpg -rotate -30 test8.jpg

By default, the empty corners that appear will be filled with white, if you want to change the color, then use the -background option:

magick IMAGE.jpg -background VioletRed -rotate 30 test8.jpg

You can see the names of all colors with the following command:

magick -list color

See also:

If you want to rotate the image and fill the empty corners with stretched bands of color around the edges of the image, then use the -distort ScaleRotateTranslate ANGLE option, for example:

magick IMAGE.jpg -distort ScaleRotateTranslate 30 test9.jpg

If you want to have the image scaled up to fill the entire space instead of filling empty edges, then use the -distort ScaleRotateTranslate SCALE,ANGLE option, for example:

magick IMAGE.jpg -distort ScaleRotateTranslate 1.5,30 test10.jpg

The -distort ScaleRotateTranslate option can take a different number of arguments, which also change its behavior:

magick IMAGE.jpg -distort ScaleRotateTranslate 500,500,30 test10.jpg

See the -distort option help for details: https://imagemagick.org/script/command-line-options.php#distort

Two more options related to rotating and flipping images:

  • -transpose: will flip the image diagonally from top left to bottom right. This option mathematically transposes an array of pixels. It is equivalent to the “-flip -rotate 90” option sequence.
  • -transverse: Flips the image diagonally from the bottom left image to the top right. Equivalent to “-flop -rotate 90”.

Examples of using:

magick IMAGE.jpg -transpose test11.jpg
magick IMAGE.jpg -transverse test11.jpg

Rolling images. Film effect

The -roll GEOMETRY option rotates the image vertically or horizontally so that its parts are on the opposite side. As an argument to the -roll option, you need to specify two numbers, which can be both positive and negative, which indicate the number of pixels by which you want to rotate the image vertically and horizontally.

Command example:

magick IMAGE.jpg -roll +130+150 test11.jpg

Result:

How to simulate a Polaroid photo on the command line

With the -polaroid ANGLE option, you can simulate a Polaroid photo.

Angle indicates how much the image should be rotated.

Command example:

magick IMAGE.jpg -polaroid -10 test12.jpg

Result:

How to reduce image noise on the Linux command line

The -noise GEOMETRY option does not work in recent versions of ImageMagick because it has been deprecated. Use -statistic NonPeak INTENSITY instead.

For example:

magick IMAGE.jpg -statistic NonPeak 3 test13.jpg

Too high INTENSITY values make the image unrealistic.

How to increase image noise on the Linux command line

To increase noise, use the following set of options: -attenuate INTENSITY +noise TYPE

For INTENSITY, enter a number (default 1.0). For Noise TYPE, select from the following options:

  • Gaussian
  • Impulse
  • Laplacian
  • Multiplicative
  • Poisson
  • Random
  • Uniform

Note that Random will replace the image with noise, not add noise to the image. Use Uniform if you want to add random noise to an image.

Command example:

magick IMAGE.jpg -attenuate 1.5 +noise Gaussian test14.jpg

Result:

You can achieve the same result with the -evaluate option, for example:

magick IMAGE.jpg -evaluate Gaussian-noise 1.5 test14.jpg

Detailed description of the -evaluate option and its possible arguments: https://imagemagick.org/script/command-line-options.php#evaluate

How to lighten or darken the edges of an image

The -raise VALUE option will lighten or darken the edges of the image to create a 3D effect.

This will create a 3D effect. Use -raise to create a raised effect, otherwise use +raise.

magick IMAGE.jpg -raise 50 test22.jpg
magick IMAGE.jpg +raise 50 test22.jpg

Unlike the similar -frame option (discussed below), -raise does not resize the image.

How to create a border around an image

To frame an image, use the -frame option.

If you want a single-color frame without effects, then specify a single number after -frame:

magick IMAGE.jpg -mattecolor peru -frame 19 test23.jpg

If you want a frame with a 3D effect, then specify four numbers: -frame AxA+B+C:

magick IMAGE.jpg -mattecolor peru -frame 19x19+3+6 test23.jpg

The first two numbers (A) determine the thickness of the frame, the second number (B) determines the thickness of the outer edge, the last number (C) determines the thickness of the inner edge.

The -mattecolor option sets the border color.

You can see the names of all colors with the following command:

magick -list color

See also:

How to create a vignette

The -vignette option softens the edges of the image in a vignette style.

Format: -vignette RADIUS{xSIGMA}{+-}x{+-}y{%}

The falloff of the vignette effect is controlled by RADIUSxSIGMA (there are two variables, radius and sigma, and the multiplication sign, i.e. radius x sigma). For nominal rolloff, this would be set to 0xsigma. A value of 0x0 will produce a circle/ellipse with no rolloff. The arguments x and y control the size of the circle. Larger values decrease the radii and smaller values increase the radii. Values of +0+0 will generate a circle/ellipse the same size as the image. The default values for x and y are 10% of the corresponding image dimension. Thus, the radii will be decreased by 10%, i.e., the diameters of the circle/ellipse will be 80% of the corresponding image dimension. Note, the percent symbol in a geometry affects x and y, whereas radius and sigma are absolute (e.g., -vignette "0x2+10%+10%").

Command examples:

magick IMAGE.jpg -vignette 20x100 test24.jpg
magick IMAGE.jpg -vignette 0x100 test24.jpg

Result of the last command:

Many examples of how to make various frames and frames for images can be found at the link: https://imagemagick.org/Usage/thumbnails/

How to lighten an image. How to increase exposure

To increase the amount of white, use the -sigmoidal-contrast NUMBER,0% option. The larger the NUMBER, the stronger the change will be, for example:

magick IMAGE.jpg -sigmoidal-contrast 4,0% test25.jpg

To reduce the amount of black, use the +sigmoidal-contrast NUMBER,100% option. The larger the NUMBER, the stronger the change will be, for example:

magick IMAGE.jpg +sigmoidal-contrast 4,100% test25.jpg

How to make an image darker. How to reduce exposure

To reduce the amount of white, use the +sigmoidal-contrast NUMBER,0% option. The larger the NUMBER, the stronger the change will be, for example:

magick IMAGE.jpg +sigmoidal-contrast 4,0% test26.jpg

To increase the amount of black, use the -sigmoidal-contrast NUMBER,100% option. The larger the NUMBER, the stronger the change will be, for example:

magick IMAGE.jpg -sigmoidal-contrast 4,100% test26.jpg

How to add a caption to a large number of images

Bulk add captions to images

The article “How to add text to images in ImageMagick” shows many examples of adding text with the ability to change all its properties using the “magick” program.

The “magick” utility is part of the ImageMagick package. For details on installing ImageMagick, including which dependencies you need to install to support the maximum number of formats, as well as a description of the command structure, examples of usage and all options, see the article: ImageMagick guide: installing, using, and troubleshooting.

But what if you need to add text to dozens or hundreds of images? This article will show you how.

Suppose there is a task to add text to all JPG files in the current directory and save them in the specified folder, while each file must be written with its original name.

First, let's note that in order not to specify each file separately, we will use “Wildcards in the file name”, that is, we will specify “*.jpg” as the input file.

As the output file, we will use “Specifying a file name pattern”.

Some “properties” must be defined in a special way in order to be used. For example, only “properties” prefixed with “filename:” can be used to change the output filename of an image.

Let's create a “withtext” directory:

mkdir withtext

The following command reads all .jpg files in the current directory one by one, adds the inscription “zaLinux.ru” to each of them, and saves the resulting images to the “withtext” directory with the same names:

magick *.jpg -stroke black -undercolor Red -strokewidth 3 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+500 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

To make it easier for you to understand, the OPTIONS FOR ADDING TEXT have been removed from the following template:

magick *.jpg OPTIONS FOR ADDING TEXT -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

The following are used as OPTIONS FOR ADDING TEXT:

-stroke black -undercolor Red -strokewidth 3 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+500 'zaLinux.ru'

If any of these options is not clear to you, then refer to the article, the link to which is given above.

Adding text can be combined with any other operations, for example, the following command compresses all JPEG images to 1000 pixels, adds text with the specified properties, and saves the new images to the “withtext” directory:

magick *.jpg -scale 1000 -stroke black -undercolor Red -strokewidth 3 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+500 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

How to add a watermark to a large number of images

Section “How to add text with transparency to a photo. How to make a translucent background for the added text” shows how to add transparent text – this approach can be used to add a watermark to a large number of images.

You can also make the text stroke partially transparent (or remove it altogether). In the following example, both the stroke (black) and text (white) are both set to opacity 0.3:

magick *.jpg -scale 1000 -stroke 'rgba(0,0,0,0.3)' -strokewidth 3 -font Liberation-Serif -pointsize 72 -fill 'rgba(255,255,255,0.3)' -annotate +650+500 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

In the following example, text is also added to all JPEG files in the current directory, the resulting images are saved in the “withtext” directory. Text properties: font color white, opacity 0.4, background color black, opacity 0.4:

magick *.jpg -scale 1000 -undercolor 'rgba(0,0,0,0.4)' -font Liberation-Serif -pointsize 72 -fill 'rgba(255,255,255,0.4)' -annotate +650+500 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

How to choose the size of the text and its coordinates depending on the size of the image

ImageMagick has the ability to do mathematical calculations using various image properties. Mathematical calculations can be done in the %[fx:…] construct.

You can see the conventions for various image properties on this page: https://imagemagick.org/script/escape.php

For example, the width in the expression [fx:…] is denoted by the letter “w”, and the height by the letter “h”.

The following expression means width divided by 2:

%[fx:w/400]

And this expression means width minus 400 pixels:

%[fx:w-400]

These expressions can be substituted as coordinates for the -annotate option.

For example, the following -annotate option will add a caption to an image, indented 400px from the right side and 25px from the bottom of the image:

-annotate +%[fx:w-400]+%[fx:h-25] 'zaLinux.ru'

Full command example:

magick IMAGE.jpg -pointsize 72 -fill 'rgba(148,0,211,0.5)' -annotate +%[fx:w-400]+%[fx:h-25] 'zaLinux.ru' test.jpg

Automatic coordinate calculation can be used in web services, to automatically add watermarks to photos on websites, or to batch process many photos.

The following command is similar to the ones already discussed, it adds a label to all JPEG images in the current folder and saves them to the “withtext” directory. The peculiarity of this command is that it automatically calculates the position of the text, placing it 400 and 25 pixels from the bottom right edge:

magick *.jpg -scale 1000 -undercolor 'rgba(0,0,0,0.4)' -font Liberation-Serif -pointsize 72 -fill 'rgba(255,255,255,0.4)' -annotate +%[fx:w-400]+%[fx:h-25] 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

And in this command, the font size, as well as the indentation from the bottom right corner, is calculated automatically, adjusting to the width and height:

magick *.jpg -scale 1000 -undercolor 'rgba(0,0,0,0.4)' -font Liberation-Serif -pointsize %[fx:w/14] -fill 'rgba(255,255,255,0.4)' -annotate '+%[fx:w-(w/2.5)]+%[fx:h-(h/23)]' 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

Note that the expression for calculating the coordinates is now in quotation marks because it uses parentheses. Parentheses are needed to indicate the priority of performing mathematical operations. And the quotes are needed for the reason that the parentheses have a special meaning for the Linux shell, and in order for them to be sent directly to the “magick” utility instead of being interpreted by the shell, the entire value of the option is placed in quotes.

The following command sets the new size of the images, and there is no need to change such parameters of the inscription as the font size and coordinates of its location – they are calculated automatically based on the width and height of the image:

magick *.jpg -scale 2000 -undercolor 'rgba(0,0,0,0.4)' -font Liberation-Serif -pointsize %[fx:w/14] -fill 'rgba(255,255,255,0.4)' -annotate '+%[fx:w-(w/2.5)]+%[fx:h-(h/23)]' 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

In the previous commands, the final image size was specified explicitly, that is, all photos were reduced to the same size. But in fact, it is not necessary to change the size of the pictures. For example, the following command will select the appropriate font size and caption coordinates so that the caption is large and legible and does not go beyond the image – the font size and padding are selected for each photo individually depending on its width and height:

magick *.jpg -undercolor 'rgba(0,0,0,0.4)' -font Liberation-Serif -pointsize %[fx:w/14] -fill 'rgba(255,255,255,0.4)' -annotate '+%[fx:w-(w/2.5)]+%[fx:h-(h/23)]' 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'
Loading...
X