Tag: multimedia

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 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 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'

How to add text to images in ImageMagick

This post covers examples of using “magick” to add text to photos. The “magick” utility is part of the ImageMagick package. For details on installing ImageMagick, including which dependencies need to be installed 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.

Text output in ImageMagick, on the one hand, is very flexible and allows you to configure any text parameters, but on the other hand, because of this flexibility, it is somewhat confusing, since there are a large number of options for setting text.

Adding a caption to ImageMagick is possible with:

  • label: – is an image type intended for creating files representing labels or for adding labels to images
  • caption: – is another type of image that differs from label: in that instead of increasing the text size to the specified “-size” parameter, it wraps any long lines that do not fit into the specified “-size” width. That is, long text is split into lines.
  • text: – is another type of image, the purpose of which is to convert large texts into a graphic format.
  • -draw – is an option that gives the command to draw one or another graphical primitive. Text is also present among graphic primitives. Currently, as a text output, it has somewhat lost its relevance due to the addition of the following option.
  • -annotate – is another option designed to conveniently add text to an image. This option uses -draw, and is intended by the author of the program as a easier and more powerful alternative to this option.

In addition to the named options, you can also note the options that are primarily responsible for metadata, but sometimes their value is also displayed along with the picture:

  • -label
  • -comment
  • -caption

What to use to display text on images in ImageMagick – label:, caption: or -annotate?

To add an inscription to the image in the choice between “-annotate” and “-draw”, we will use the advice of the author of the program and we will use “-annotate”.

As far as “label:” and “caption:” are concerned, these images also have some advantages. For example, “caption:” can distribute long text into lines so that it fits in a certain area. And “label:” knows how to select the font size so that it fits best into the given size.

But with all its capabilities, “label:” and “caption:” are still images, so when you add text to them, it has a background. However, if desired, the background can be made transparent.

The “-annotate” option can also output text with the specified background color, but by default it only outputs text without any background.

All three variants (“label:”, “caption:” and “-annotate”) can display multiline text, but only “caption:” can automatically span text across multiple lines.

In general, “-annotate” seems to be a more universal option when you need to add text to an image.

The “label:” and “caption:” options are best suited when you need to add a caption not on the image itself, but below or above it, or even on the image, but on the background and within the specified size. Also “label:” and “caption:” are handy when you need to create a new image consisting of a caption, such as a button for a web interface.

Options for -annotate

This section contains all the options that affect the text shown with -annotate. Further, each of the options is considered in more detail and examples of its use are given, and this section can be used as a quick reference to quickly find the desired option.

If any option related to -annotate is missing, then write about it in the comments.

  • -pointsize. Font size.
  • -font. The name of the font.
  • -family. Font family.
  • -fill. Font color.
  • -stroke. Stroke (outline) color.
  • -strokewidth. Stroke thickness.
  • -style. Style, for example, italic, oblique, normal.
  • -undercolor. Undercolor (background) color.
  • -gravity. Sets the origin.
  • -weight. The font weight that is trying to apply to the Font family.
  • -antialias. Turns anti-aliasing on and off.
  • -kerning. Distance between two letters.
  • -interword-spacing. Distance between two words.
  • -interline-spacing. The distance between two lines.
  • -stretch. Deprecated and removed.
  • -text-font. Deprecated and removed.

How to add text to an image on the Linux command line

To add text, use the -annotate {+-}tx{+-}ty TEXT option

In this line:

  • {+-}tx – horizontal offset in pixels from the center of gravity (by default, from the upper left corner)
  • {+-}ty – vertical offset in pixels from the center of gravity (by default, from the upper left corner)
  • TEXT – text to add to the image

The following command will add the inscription “zaLinux.ru” to the photo, shifting it from the left border by 20 pixels and from the top by 50 pixels:

magick IMAGE.jpg -annotate +20+50 'zaLinux.ru' test40.jpg

By default, text is black and has a very small font size. Therefore, if you do not see the text, then go to the next option.

How to change font size in ImageMagick

To change the size, use the -pointsize SIZE option.

Command example:

magick IMAGE.jpg -pointsize 72 -annotate +20+50 'zaLinux.ru' test40.jpg

How to change font color in ImageMagick

To change the font color, use the -fill COLOR option. This parameter accepts a color name, a hexadecimal color, or an RGB, RGBA, HSL, HSLA, CMYK, or CMYKA numeric specification. You can see the names of all colors in the How to specify color in ImageMagick section.

Enclose the color specification in quotation marks so that “#” or parentheses are not interpreted by your shell.

Colors can be specified in the following format (the list is not complete, see the previous link for more details):

  • -fill blue
  • -fill "#ddddff"
  • -fill "rgb(255,255,255)"

An example of a command that will write the text “zaLinux.ru” on the photo IMAGE.jpg with a size of 72 pt and the color DarkViolet, the text will be placed with an indent of 500 pixels from the left edge of the image and 450 pixels from the top edge, the file with the inscription will be saved with the name test40. jpg:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -annotate +500+450 'zaLinux.ru' test40.jpg

How to change font in ImageMagick

Use the -font FONT NAME option to select a font. This option will set the font to be used when annotating images with text or creating labels.

The command will show the full list of fonts:

magick -list font

For each font, information from several lines will be displayed, the line with the name of the font begins with “Font:”. It is this name that must be used with the -font option.

In addition to the fonts listed in the predefined list above, you can also specify a font from a specific source. For example, Arial.ttf is a TrueType font file, ps:helvetica is a PostScript font, and “x:fixed” is an X11 font.

To explicitly name a file or collection of fonts, specify the path to the font preceded by the @ character, such as @arial.ttf. You can specify the font weight index for font collections, eg @msgothic.ttc[1].

The following command adds a caption using the Utopia-Regular font:

magick IMAGE.jpg -font Utopia-Regular -pointsize 72 -fill DarkViolet -annotate +500+450 'zaLinux.ru' test41.jpg

The result of the following command

magick IMAGE.jpg -font Utopia-Regular -pointsize 72 -fill DarkViolet -annotate +500+150 'zaLinux.ru' -font Ubuntu -pointsize 72 -fill DarkViolet -annotate +500+250 'zaLinux.ru' -font Cormorant-Unicase-Bold -pointsize 72 -fill DarkViolet -annotate +500+350 'zaLinux.ru' -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +500+450 'zaLinux.ru' -font Liberation-Serif -pointsize 72 -fill DarkViolet -annotate +500+550 'zaLinux.ru' test41.jpg

How to specify a font family

The -family FONT FAMILY option sets the font family for the text.

This setting suggests the font family that ImageMagick should try to use to render text. If a family can be found, it is used; if not, the default font is substituted (for example, “Arial”) or a family known to be similar (for example, “Courier” can be used if “System” is requested but not found). Note that the family can be a list of CSS style fonts.

If the FONT FAMILY name contains spaces, then put it in quotation marks, for example, the following command specifies the URW Gothic font-family:

magick IMAGE.jpg -family 'URW Gothic' -pointsize 72 -fill DarkViolet -annotate +500+450 'zaLinux.ru' test42.jpg

How to stroke text

With the two options -stroke STROKE COLOR and -strokewidth STROKEWIDTH, you can specify the color and thickness of the text stroke.

For example, in the following command, the text in the DarkViolet font is selected, the stroke color is black, and the stroke weight is set to 3:

magick IMAGE.jpg -stroke black -strokewidth 3 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +500+550 'zaLinux.ru' test43.jpg

The result of the command execution (shown strokes with a width of 1 to 5):

magick IMAGE.jpg -stroke black -strokewidth 1 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+50 'zaLinux.ru' -stroke black -strokewidth 2 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+150 'zaLinux.ru' -stroke black -strokewidth 3 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+250 'zaLinux.ru' -stroke black -strokewidth 4 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+350 'zaLinux.ru' -stroke black -strokewidth 5 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+450 'zaLinux.ru' -stroke black -strokewidth 6 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+550 'zaLinux.ru' test43.jpg

How to make a font italic or oblique

With the -style option, you can specify the font style, the following options are available:

  • Any
  • Italic
  • Normal
  • Oblique

You can display the full list of styles with the command:

magick -list style

Command result

magick IMAGE.jpg -style Any -family 'Times New Roman' -pointsize 72 -fill DarkViolet -annotate +650+150 'zaLinux.ru' -style Italic -family 'Times New Roman' -pointsize 72 -fill DarkViolet -annotate +650+250 'zaLinux.ru' -style Normal -family 'Times New Roman' -pointsize 72 -fill DarkViolet -annotate +650+350 'zaLinux.ru' -style Oblique -family 'Times New Roman' -pointsize 72 -fill DarkViolet -annotate +650+450 'zaLinux.ru' test44.jpg

How to change the text background color

To change the background, use the -undercolor COLOR option.

You can see the names of all colors in the How to specify color in ImageMagick section.

Command example:

magick IMAGE.jpg -undercolor Red -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +650+150 'zaLinux.ru' test45.jpg

How to change the origin of coordinates

In the previous commands, the coordinates were counted from the upper left corner. With the -gravity TYPE option, you can choose a different area as the origin.

The following values are available as TYPE:

  • None
  • Center
  • East
  • Forget
  • NorthEast
  • North
  • NorthWest
  • SouthEast
  • South
  • SouthWest
  • West

Result of command execution:

magick IMAGE.jpg -gravity None -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'None' -gravity Center -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'Center' -gravity East -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'East' -gravity Forget -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'Forget' -gravity NorthEast -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'NorthEast' -gravity North -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'North' -gravity NorthWest -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'NorthWest' -gravity SouthEast -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'SouthEast' -gravity South -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'South' -gravity SouthWest -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'SouthWest' -gravity West -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'West' test46.jpg

See also The -gravity option defines the origin for the Offset.

How to enable or disable anti-aliasing when adding labels

Using the -antialias and +antialias options, you can turn on/off the rendering of anti-aliasing pixels when drawing fonts and lines.

By default, objects (such as text, lines, polygons, etc.) are anti-aliased when drawn, so the -antialias option is used by default and does not need to be specifically specified.

Use +antialias to disable the addition of antialiasing edge pixels. This will reduce the number of colors added to the image to those that are directly drawn. That is, when drawing such objects, mixed colors are not added.

The following command has label antialiasing enabled (the -antialias option is implied by default and can be omitted):

magick IMAGE.jpg -antialias -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +650+150 'zaLinux.ru' test47.png

This command disables caption smoothing (antialiasing):

magick IMAGE.jpg +antialias -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +650+150 'zaLinux.ru' test48.png

In my tests, the +antialias option either does not work with the JPG format, or as a result of the format's lossy compression, anti-aliasing cancel is not noticeable.

The result of disabling anti-aliasing is clearly visible in a PNG photo. Differences are visible both without magnification and when the image is enlarged. Without magnification, the inscription seems unnaturally sharp. At high magnification, when anti-aliasing is turned off, you can see that there are no transition pixels.

When anti-aliasing is enabled, transitional pixels are visible, the colors of which differ both from the color of the inscription and from the background.

How to set font thickness

With the -weight option, you can specify the weight of the font that is trying to apply to the font family.

This option suggests the font weight that ImageMagick should try to apply to the selected font family. Use a positive integer or choose one of the following notations:

Thin			Same as fontWeight = 100.
ExtraLight		Same as fontWeight = 200.
Light			Same as fontWeight = 300.
Normal			Same as fontWeight = 400.
Medium			Same as fontWeight = 500.
DemiBold		Same as fontWeight = 600.
Bold			Same as fontWeight = 700.
ExtraBold		Same as fontWeight = 800.
Heavy			Same as fontWeight = 900.

You can view the full list of options for this option with the command:

magick -list weight

An example of the following command

magick IMAGE.jpg -weight 100 -family 'Ubuntu' -pointsize 72 -fill DarkViolet -annotate +500+70 'zaLinux.ru' -weight 300 -family 'Ubuntu' -pointsize 72 -fill DarkViolet -annotate +500+170 'zaLinux.ru' -weight 500 -family 'Ubuntu' -pointsize 72 -fill DarkViolet -annotate +500+270 'zaLinux.ru' -weight 700 -family 'Ubuntu' -pointsize 72 -fill DarkViolet -annotate +500+370 'zaLinux.ru' -weight 900 -family 'Ubuntu' -pointsize 72 -fill DarkViolet -annotate +500+470 'zaLinux.ru' test49.jpg

As you can understand, depending on the specified “weight”, one of the font options (Light, Normal, Semi-Bold, Bold) is selected, which is most suitable. Keep in mind that not all fonts have versions, so for some fonts the result will be the same regardless of what is specified with the -weight option.

Also, if you specify a specific font using the -font option instead of the -family option, then regardless of the -weight value, the label will always look the same, because in the case of -family, a choice is made from several fonts, and in the case of -font, one font is always used.

How to change letter spacing

With the -kerning option, you can specify the spacing between two letters.

Command execution example

magick IMAGE.jpg -kerning 5 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+70 'zaLinux.ru' -kerning 10 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+160 'zaLinux.ru' -kerning 15 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+250 'zaLinux.ru' -kerning 20 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+340 'zaLinux.ru' -kerning 25 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+430 'zaLinux.ru' -kerning 30 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+520 'zaLinux.ru' test50.jpg

How to change word spacing

With the -interword-spacing option you can set the spacing between two words.

Command execution example:

magick IMAGE.jpg -interword-spacing 5 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+70 'zaLinux.ru and HackWare.ru' -interword-spacing 20 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+160 'zaLinux.ru and HackWare.ru' -interword-spacing 35 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+250 'zaLinux.ru and HackWare.ru' -interword-spacing 50 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+340 'zaLinux.ru and HackWare.ru' -interword-spacing 65 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+430 'zaLinux.ru and HackWare.ru' -interword-spacing 80 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+520 'zaLinux.ru and HackWare.ru' test51.jpg

The value specified as the distance can be either positive or negative.

How to change line spacing

With the -interline-spacing option you can set the spacing between two lines.

The value specified as the distance can be either positive or negative.

magick IMAGE.jpg -interline-spacing -30 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+70 'zaLinux.ru\nand\nHackWare.ru' -interline-spacing 50 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +550+270 'zaLinux.ru\nand\nHackWare.ru' test52.jpg

How to add rotated and slanted text to a photo

You can make text slanted with additional arguments to the -annotate option.

The option can be applied with the following set of arguments:

  • -annotate DEGREES TEXT
  • -annotate X_DEGREESxY_DEGREES TEXT
  • -annotate X_DEGREESxY_DEGREES {+-}tx{+-}ty TEXT
  • -annotate {+-}tx{+-}ty TEXT

In these lines:

  • DEGREES – the angle of rotation of the entire text, without distortion
  • X_DEGREES – shift angle of the right edge of the text relative to the left edge of the text
  • Y_DEGREES – the angle of shift of the top edge of the text relative to the bottom edge of the text
  • {+-}tx – horizontal offset in pixels from the center of gravity (by default, from the upper left corner)
  • {+-}ty – vertical offset in pixels from the center of gravity (by default, from the upper left corner)
  • TEXT – text to add to the image

All previous examples use only one syntax: -annotate {+-}tx{+-}ty TEXT

Command execution example:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate 0x0+25+70 '1. zaLinux.ru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate 0x50+125+170 '2. zaLinux.ru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate 50x0+225+270 '3. zaLinux.ru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate 50x30+425+270 '4. zaLinux.ru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate 50x+625+270 '5. zaLinux.ru' test53.jpg

Please note that in order for the text to turn out to be rotated, but without distortion, the degrees must be the same.

How to insert multiline text

Multiline text can be inserted in a variety of ways. ImageMagick understands the “\n” character as a newline character:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +125+270 'zaLinux\n.\nru' test54.jpg

You can also tritely insert newline characters added to the image text:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +125+270 'zaLinux
.
ru' test54.jpg

You can also create a file with a multi-line record in advance. If you put the @ symbol before the filename, the program will try to find and read the given file. In the following command, the caption for the photo will be added from the mytext.txt file:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +125+270 @mytext.txt test54.jpg

To read standard input, use the @- construct.

Result of command execution:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +125+270 'zaLinux\n.\nru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +425+270 'zaLinux
.
ru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +725+270  @mytext.txt test54.jpg

How to use “label:” and “caption:” to add an image

Recall the essence of label: and caption:

  • label: – image type intended for creating files representing labels or for adding labels to images
  • caption: – another type of image that differs from “label:” in that instead of increasing the text size to the specified “-size” parameter, it wraps any long lines that do not fit into the specified “-size” width. That is, long text is broken into lines.

An example of creating an image with text:

magick -background lightblue -fill DarkViolet -font Utopia-Regular -pointsize 72 label:ZaLinux.ru label.png

Instead of specifying the size with the “-pointsize” option, you can specify the size of the image (width and height, or just the width) with the “-size” option:

magick -background lightblue -fill DarkViolet -font Utopia-Regular -size 300 label:ZaLinux.ru label-size.png

You can use the “-pointsize” and “-size” options at the same time, but then the size of the text and image may not match.

Any of the options discussed above can be used to set font and label properties.

label: and caption: support multiline input.

If you want to add a caption to an image using “label:” or “caption:”, then use the options from the article “How to composite and append images on the Linux command line (overlay and merge images)”.

For example, the following command will create a caption and add it to an image:

magick IMAGE.jpg \( -background lightblue -fill DarkViolet -font Utopia-Regular -size 1000 label:ZaLinux.ru \) -append test60.jpg

The following command is very similar to the previous one, with the difference that the first image is the caption, and then comes the photo, resulting in the caption being above the image:

magick \( -background lightblue -fill DarkViolet -font Utopia-Regular -size 1000 label:ZaLinux.ru \) IMAGE.jpg -append test61.jpg

You can place an image with an inscription anywhere in the photo, to do this, specify the coordinates of the image using the -geometry option:

magick IMAGE.jpg \( -background lightblue -fill DarkViolet -font Utopia-Regular -size 400 label:ZaLinux.ru \) -geometry +400+450 -composite test62.jpg

Using the -gravity option, you can place an inscription in one or another area of the image without specifying its coordinates, or change the origin of coordinates. The following command is to place the caption at the bottom of the photo:

magick IMAGE.jpg \( -background lightblue -fill DarkViolet -font Utopia-Regular -size 400 label:ZaLinux.ru \) -gravity South -geometry +0+0 -composite test63.jpg

This command places the caption in the very center of the photo:

magick IMAGE.jpg \( -background lightblue -fill DarkViolet -font Utopia-Regular -size 400 label:ZaLinux.ru \) -gravity Center -geometry +0+0 -composite test64.jpg

How to use “label:” or “caption:” to add a caption without a background

To add a caption without a background using “label:” or “caption:” you need to use the following options:

  • -transparent white – makes the background transparent
  • +antialias – disables anti-aliasing, otherwise the inscription will turn out with white spots

Command example:

magick IMAGE.jpg \( -size 320x100 +antialias -fill blue label:'ZaLinux.ru' -transparent white \) -composite test.jpg

Another way to make the background completely transparent is to initially specify a color with full transparency. To learn how to do this, see How to specify a color with transparency.

Command example:

magick IMAGE.jpg \( -background 'rgba(255,255,255,0)' -fill DarkViolet -font Utopia-Regular -size 400 label:ZaLinux.ru \) -gravity South -geometry +0+0 -composite test65.jpg

How to add text with transparency to a photo. How to make a translucent background for the added image

You can use partially transparent colors for:

  • adding text with transparency to a photo
  • creating a transparent background for the added inscription
  • to add a watermark to an image

In all cases, you can use the commands shown above, in order for the color to become transparent, just select the transparency level in the color properties. To learn how to do this, see How to specify a color with transparency.

An example of a command using a partially transparent color:

magick IMAGE.jpg -pointsize 72 -fill 'rgba(148,0,211,0.5)' -annotate +650+150 'zaLinux.ru' test.jpg

The following command uses text with transparency for the caption and for the background of the text:

magick IMAGE.jpg -undercolor 'rgba(148,0,211,0.1)' -pointsize 72 -fill 'rgba(0,0,128,0.5)' -font Liberation-Serif -annotate +650+450 'zaLinux.ru' test66.jpg

You can also use transparent colors with “label:” or “caption:” (for both background and caption), like so:

magick IMAGE.jpg \( -background 'rgba(148,0,211,0.1)' -fill 'rgba(0,0,128,0.5)' -font Utopia-Regular -size 400 label:ZaLinux.ru \) -geometry +400+450 -composite test.jpg

See the continuation: How to add a caption to a large number of images.

How to composite and append images on the Linux command line (overlay and merge images)

The “magick” utility is part of the ImageMagick package. For details on installing ImageMagick, including which dependencies need to be installed 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.

Let’s consider how to overlay an image on an image and merge images.

The command to overlay one image on another consists of three main parts:

  1. The name of the initial image that will act as the background.
  2. The name of the second image to overlay the first. Geometry options, as well as the “-composite” option. This item can be repeated many times to overlay several images on one.
  3. The name of the output file.

In the following example, IMAGE.jpg will be overlaid with IMAGE1.jpg, whose width will be 400 pixels, this image will be shifted from the left edge by 50 pixels and from the top by 10 pixels, the new image will be saved to the test27.jpg file:

magick IMAGE.jpg IMAGE1.jpg -geometry 400x300+50+10 -composite test27.jpg

Please note that the overlay image will have a width of 400 pixels, and the height will be adjusted automatically to maintain the original proportions of the image, see the Image Geometry section for details.

If you want to place the image in the center, in one of the corners, or in the middle of one of the sides, then instead of specifying an offset, you can use the -gravity option.

With the -gravity option you can change the origin, for example:

magick IMAGE.jpg IMAGE1.jpg -gravity North -geometry 400x300+0+0 -composite test27.jpg
magick IMAGE.jpg IMAGE1.jpg -gravity South -geometry 400x300+0+0 -composite test27.jpg
magick IMAGE.jpg IMAGE1.jpg -gravity SouthWest -geometry 400x300+0+0 -composite test27.jpg

See also The -gravity option defines the origin for the Offset.

A similar command, in which images from IMAGE1.jpg to IMAGE6.jpg are superimposed on the IMAGE.jpg image:

magick IMAGE.jpg IMAGE1.jpg -geometry 400x300+50+10 -composite IMAGE2.jpg -geometry 330x230+225+210 -composite IMAGE3.jpg -geometry 350x300+475+260 -composite IMAGE4.jpg -geometry 400x300+25+410 -composite IMAGE5.jpg -geometry 400x300+625+10 -composite IMAGE6.jpg -geometry 350x300+600+450 -composite test28.jpg

Note that the -composite option is applied after each image!

To better understand the logic, brackets have been added to the previous command that combine the image and its settings, this command does not differ from the previous one in its result:

magick IMAGE.jpg \( IMAGE1.jpg -geometry 400x300+50+10 \) -composite \( IMAGE2.jpg -geometry 330x230+225+210 \) -composite \( IMAGE3.jpg -geometry 350x300+475+260 \) -composite \( IMAGE4.jpg -geometry 400x300+25+410 \) -composite \( IMAGE5.jpg -geometry 400x300+625+10 \) -composite \( IMAGE6.jpg -geometry 350x300+600+450 \) -composite b.jpg

Since the height is selected automatically, it can be omitted:

magick IMAGE.jpg IMAGE1.jpg -geometry 400x+50+10 -composite IMAGE2.jpg -geometry 330x+225+210 -composite IMAGE3.jpg -geometry 350x+475+260 -composite IMAGE4.jpg -geometry 400x+25+410 -composite IMAGE5.jpg -geometry 400x+625+10 -composite IMAGE6.jpg -geometry 350x+600+450 -composite b.jpg

As a background, instead of a photo, you can specify the background color, for this use the -size SIZE canvas:COLOR set of options. For example, the following command overlays images on a 1000×750 red background:

magick -size 1000x750 canvas:red IMAGE1.jpg -geometry 400x300+50+10 -composite IMAGE2.jpg -geometry 330x230+225+210 -composite IMAGE3.jpg -geometry 350x300+475+260 -composite IMAGE4.jpg -geometry 400x300+25+410 -composite IMAGE5.jpg -geometry 400x300+625+10 -composite IMAGE6.jpg -geometry 350x300+600+450 -composite test29.jpg

How to merge photos without overlay

The -append option connects the current images vertically or horizontally with +append.

This option creates one longer image by concatenating all current images in sequence from top to bottom.

magick IMAGE.jpg IMAGE1.jpg -append test31.jpg

Use +append to add images from left to right.

magick IMAGE.jpg IMAGE1.jpg +append test31.jpg

If they have different widths, the narrower images are padded with the current background color setting, and their position relative to each other can be controlled by the current -gravity setting.

The background color can be set with the -background COLOR option. For example:

magick IMAGE.jpg -background Violet IMAGE1.jpg -append test30.jpg

You can also use the -scale option to scale images to the same size:

magick IMAGE.jpg -scale 1000 IMAGE1.jpg -scale 1000 -append test30.jpg

The previous command will bring both images to a width of 1000px and stack them on top of each other.

A similar command, but instead of placing the images on top of each other, it will place them from left to right (horizontally):

magick IMAGE.jpg -scale 1000 IMAGE1.jpg -scale 1000 +append test30.jpg

For more flexible options, including the ability to add space between images, use -smush.

The -smush OFFSET option adds a sequence of images together, ignoring transparency.

-smush is a more flexible version of -append, joining images in sequence from top to bottom (-smush) or left to right (+smush) with spacing between images according to the specified offset.

If the offset is negative, the images will overlap by that amount.

-smush respects -gravity. Any empty space will be filled with the background color.

For zero offset images and transparent images, the opaque parts of the two images will be aligned as closely as possible without overlapping.

An example of a command with the -smush option (brings images to the same width of 1000 pixels and places them on top of each other, separated by a space of 100 pixels):

magick IMAGE.jpg -scale 1000 -background Violet IMAGE1.jpg -scale 1000 -smush 100 test31.jpg

How to connect a TV to a computer in Windows 11

Is it possible to connect a TV or a second monitor to a computer in Linux

This guide will show you how to connect a TV or a second monitor to a computer in Windows 11. It will also talk about the available settings and solutions to common problems that arise when connecting a TV to a computer.

If you are a Linux user, then see the articles:

What you need to connect a TV or an additional monitor to a computer

To connect a TV or a second monitor to a computer or laptop, you need:

  • TV with HDMI connector (all modern models) or monitor with HDMI connector (all monitors released in the last two decades)
  • a computer with an HDMI connector – almost all computers and laptops will fit
  • HDMI cable

Choosing an HDMI cable

I approached the choice of HDMI cable quite simply – I chose the cheapest with the right length, which I found in the store. In subsequent use, this cable fully satisfied my needs.

Despite its cheapness, this HDMI cable supports:

  • UHD 4K@2160P / 4K@60Hz / 4K HDR
  • High Speed HDMI 2.0
  • Gold plated contacts

Cable length 1.8 meters.

Apparently, these are already the minimum characteristics – perhaps more expensive models support higher resolutions and data transfer at higher speeds.

What TV can be connected to a computer

Using an HDMI cable, you can connect any TV with an HDMI connector. This connector is present on all TVs and monitors released in the last decade.

Older TVs without an HDMI connector can also be connected to a computer, but instead of an HDMI cable, you will need a wire with an adapter.

As for the technical characteristics of the TV (diagonal size, screen resolution, screen refresh rate, aspect ratio), this is not critical. That is, you do not have to select a TV model with the same characteristics as your monitor. Modern video cards support a variety of modes (screen resolutions and refresh rates), including the video card will work with a TV if the screen resolution is different from the monitor.

For example, the characteristics of my devices:

  • laptop monitor: 17", 1920×1080, 16:9, 120 Hz
  • TV (all specifications): 32", 1366x768p, 16:10, 60Hz

That is, these are two very different devices, but at the same time I had no problems when they worked together.

How to connect HDMI cable to TV

Plug the HDMI cable into the connectors of the computer (laptop) and TV.

Both on the computer and on the TV, there may be several HDMI connectors – remember the number of the selected connector.

Turn on your computer and TV.

Note: The HDMI cable can be connected when the computer and TV are already on.

Use the remote control to select “HDMI” as the input source on the TV.

If, after selecting HDMI as the signal source on the TV, you see the message “No Input Signal”, then:

  1. Select HDMI with a different number.
  2. Move the wire, it may not be firmly connected to the computer or TV socket.
  3. Make sure your computer is on.
  4. The monitor on the computer should not be turned off due to inactivity.

How to use a TV connected to a computer

There are two main modes:

  • join displays
  • mirror (duplication) of images on both displays

When displays are combined, the total space expands. That is, if you connected another 1920×1080 display to a computer with one 1920×1080 display, then now the resolution of your virtual screen becomes 3840×1080, if there are three such displays, the resolution will become 5760×1080. You can drag program windows from one display to another. Some apps and games support these wide virtual screens.

When the image is repeated (Mirror), the same image will be shown on both displays.

Among the displays, Primary stands out. This is the one connected first. A feature of the main display is that it shows desktop shortcuts, although this can be changed in the settings.

In the next video, the TV is connected to the computer. To play a YouTube video on a TV, the web browser window is dragged from the monitor to the TV.

Where are the settings for the second display and TV

Open the “Settings” app by pressing Win+i.

Go to the “Display” section.

Here you will see the display settings.

Select the display (or TV) you want to customize.

At the top of the settings window, you'll see a display layout.

The “Multiple displays” settings area appears only if multiple monitors (TVs) are connected to the computer, it contains settings for the computer's behavior when working with multiple displays. To see these settings, click on the arrow icon on the right side.

The following are settings common to all displays.

Then at the bottom of the window are settings specific to each display.

Select a monitor to change its settings.

The following settings are individual for each monitor:

  • Scale
  • Display resolution
  • Display orientation

When you go to the “Advanced display” settings section, you will also be able to adjust the refresh rate for each of the displays.

How to set Main (Primary) Monitor

By default, desktop shortcuts are shown on the Main Display. You can change, i.e. choose a new primary monitor. For this:

1. Open the “Settings” application, this can be done by pressing Win+i.

2. Go to the “Display” section.

3. Select the display you want to make Primary.

4. Expand the “Multiple displays” settings area.

5. Check the “Make this my main display” checkbox.

How to turn off the display or TV in the settings, without physically disconnecting

You can disconnect the HDMI cable from your TV or computer at any time, but this is not always convenient. In addition, you may want to turn off the computer monitor or the laptop's built-in monitor.

To turn off any monitor or TV in Settings, open the “Settings” app by pressing Win+i.

Go to the “Display” section.

Below the monitor layout, you will see a drop-down list of the following items:

  • Duplicate these displays
  • Extend these displays
  • Show only on 1
  • Show only on 2

Selecting the “Show only on…” option will cause the image to be displayed on only one display (or TV), and all others will be disabled.

A disabled monitor will stop working (it will no longer receive an input signal), but the disabled monitor will still be available in the settings. You can turn it back on at any time. To enable all monitors, select one of the following options from the drop-down list above:

  • Duplicate these displays
  • Extend these displays

How to make the TV show the same thing as the monitor

Open the “Settings” app by pressing Win+i.

Go to the “Display” section.

Under the monitor layout, select “Duplicate these displays” from the drop-down list.

As a result, the resulting settings for both monitors at once will be shown.

Now the image on the monitor and TV is the same:

You may notice that the picture on the TV is slightly cropped.

This may be due to the aspect ratio or screen resolution.

In my case, both the aspect ratio and the screen resolution of the monitor built into the laptop and the TV are different. Changing the screen resolution to what the TV has somewhat reduced the problem with cut edges.

How to make the TV become an extension of the monitor

Open the “Settings” app by pressing Win+i.

Go to the “Display” section.

Under the monitor layout, select “Extend these displays” from the drop-down list.

In this case, one of the monitors will be considered the main one. In this case, each of the monitors will show its own desktop, which, in fact, is one.

Why can't I drag the program window to the second screen

If you see two displays in the settings, but you can’t drag the program window to the TV or the second display, then try dragging the window to the other side. That is, if you, for example, are trying to drag a program window to the left side, then try dragging it to the right side instead.

The fact is that the physical location of the second monitor (TV) and its location in the settings can be different. To fix this, swap the monitors in the settings.

In addition to the location of the monitors to the left and right of each other, other options are possible.

You can place one of the monitors (or TVs) above the other.

In this case, the screen resolution and desktop area will change accordingly.

If you have many monitors, you can place them however you want, not all monitors need to be in a straight line horizontally. You can arrange them, for example, as 3×2, that is, two rows of three monitors.

How to make the Taskbar only show on the Main monitor

If you want the taskbar to be shown only on the Main monitor, then follow the steps below.

Open the “Settings” app by pressing Win+i.

Go to “Personalization” → “Taskbar”.

Expand the “Taskbar behavior” section.

Uncheck the “Show my taskbar on all displays” setting.

How to make the taskbar show on all monitors

If you want the taskbar to be shown on all connected monitors and TVs, then follow these steps.

Open the “Settings” app by pressing Win+i.

Go to “Personalization” → “Taskbar”.

Expand the “Taskbar behavior” section.

Check the box next to “Show my taskbar on all displays”.

After that, the Taskbar will be shown on all monitors.

How to set different desktop wallpapers for monitor and TV

You can set a different desktop wallpaper for all connected monitors and TVs.

To do this, open the “Settings” application, this can be done by pressing Win+i.

Go to “Personalization” → “Background”.

Right click on the photo you want to set as your desktop wallpaper. From the pop-up menu, select the number of the monitor for which you want to set this desktop background.

Now the desktop wallpaper on the monitor and TV is different.

How to identify displays

If you have multiple monitors and you are confused about their settings, then you can enable the display of the number on the screen of each monitor.

Open the “Settings” app by pressing Win+i.

Go to the “Display” section.

Click the “Identify” button, which is located under the schematic image of the monitors.

After that, each monitor and TV will show squares with display numbers in the settings.

Why is the sound played through a computer (laptop) and not through a TV

An HDMI cable can carry both video and audio. But even after connecting the TV with an HDMI cable, sound is still output from the laptop speakers or computer speakers.

To change the audio output source, go to the audio settings. To do this, open the “Settings” application, this can be done by pressing Win+i.

Go to the “Sound” section.

In the “Output” section, select “Audio for Displays”.

You can also expand the settings for each sound source by clicking the arrow symbol to the right of the source name. In the window that opens, you can fine-tune each sound source.

Why did the sound disappear after turning off the TV on the laptop (computer)

To change the audio output source, go to the audio settings. To do this, open the “Settings” application, this can be done by pressing Win+i.

Go to the “Sound” section.

In the “Output” section, select “Speakers”.

Setting the action when closing the laptop lid when using a second monitor

If you are using a laptop, closing the laptop lid when additional monitors are connected to it may not be what you expect. For example, when you close the laptop lid, the computer goes into Sleep mode or shuts down, but you expect to be able to work on a second monitor or watch TV connected to the computer.

To control how the computer behaves when the laptop lid is closed, open the “Control Panel”.

In the Control Panel, go to “Category” → “Small icons”.

Open the “Power Options” section.

Click on the “Choose what closing the lid does” link.

You can also go to this setting by running the command:

control /name Microsoft.PowerOptions /page pageGlobalSettings

In the window that opens, note that all actions are configured for two modes:

  • On battery
  • Plugged in

For the action for “When I close the lid”, select “Do nothing”.

How to prevent the monitor from turning off

If there is no activity for some time (for example, 10 minutes), the monitors will be turned off. You can disable the setting to turn off displays.

To control when monitors turn off due to inactivity, open the “Control Panel”.

In the “Control Panel”, go to “Category” → “Small icons”.

Open the “Power Options” section.

Click on the “Choose when to turn off the display” (or “Change when the computer sleeps” link).

You can also go to this setting by running the command:

control /name Microsoft.PowerOptions /page pagePlanSettings

In the window that opens, note that all actions are configured for two modes:

  • On battery
  • Plugged in

Set longer time intervals before turning off the monitor and entering sleep mode, or select “Never”.

How to connect a TV to a computer in Linux in GNOME (Ubuntu)

Is it possible to connect a TV or a second monitor to a computer in Linux

This post will show you how to connect a TV or a second monitor to a Linux computer with the GNOME desktop environment. It will also talk about the available settings and solutions to typical problems that arise when connecting a TV to a computer.

GNOME is used in distributions such as Ubuntu, and the GNOME desktop environment can be installed on any other distribution.

If you have a different desktop environment, then see the articles:

If you are a Windows user, then see the article “How to connect a TV to a computer in Windows 11”.

What you need to connect a TV or an additional monitor to a computer

To connect a TV or a second monitor to a computer or laptop, you need:

  • TV with HDMI connector (all modern models) or monitor with HDMI connector (all monitors released in the last two decades)
  • a computer with an HDMI connector – almost all computers and laptops will fit
  • HDMI cable

Choosing an HDMI cable

I approached the choice of HDMI cable quite simply – I chose the cheapest with the right length, which I found in the store. In subsequent use, this cable fully satisfied my needs.

Despite its cheapness, this HDMI cable supports:

  • UHD 4K@2160P / 4K@60Hz / 4K HDR
  • High Speed HDMI 2.0
  • Gold plated contacts

Cable length 1.8 meters.

Apparently, these are already the minimum characteristics – perhaps more expensive models support higher resolutions and data transfer at higher speeds.

What TV can be connected to a computer

Using an HDMI cable, you can connect any TV with an HDMI connector. This connector is present on all TVs and monitors released in the last decade.

Older TVs without an HDMI connector can also be connected to a computer, but instead of an HDMI cable, you will need a wire with an adapter.

As for the technical characteristics of the TV (diagonal size, screen resolution, screen refresh rate, aspect ratio), this is not critical. That is, you do not have to select a TV model with the same characteristics as your monitor. Modern video cards support a variety of modes (screen resolutions and refresh rates), including the video card will work with a TV if the screen resolution is different from the monitor.

For example, the characteristics of my devices:

  • laptop monitor: 17", 1920×1080, 16:9, 120 Hz
  • TV (all specifications): 32", 1366x768p, 16:10, 60Hz

That is, these are two very different devices, but at the same time I had no problems when they worked together.

How to connect HDMI cable to TV

Plug the HDMI cable into the connectors of the computer (laptop) and TV.

Both on the computer and on the TV, there may be several HDMI connectors – remember the number of the selected connector.

Turn on your computer and TV.

Note: The HDMI cable can be connected when the computer and TV are already on.

Use the remote control to select “HDMI” as the input source on the TV.

If, after selecting HDMI as the signal source on the TV, you see the message “No Input Signal”, then:

  1. Select HDMI with a different number.
  2. Move the wire, it may not be firmly connected to the computer or TV socket.
  3. Make sure your computer is on.
  4. The monitor on the computer should not be turned off due to inactivity.

How to use a TV connected to a computer

There are two main modes:

  • join displays
  • mirror (duplication) of images on both displays

When displays are combined, the total space expands. That is, if you connected another 1920×1080 display to a computer with one 1920×1080 display, then now the resolution of your virtual screen becomes 3840×1080, if there are three such displays, the resolution will become 5760×1080. You can drag program windows from one display to another. Some apps and games support these wide virtual screens.

When the image is repeated (Mirror), the same image will be shown on both displays.

Among the displays, Primary stands out. This is the one connected first. A feature of the main display is that it shows desktop shortcuts, although this can be changed in the settings.

In the next video, the TV is connected to the computer. To play a YouTube video on a TV, the web browser window is dragged from the monitor to the TV. The video begins by selecting HDMI as the audio output source to play audio on a TV instead of playing it on a computer (laptop).

Where are the settings for the second display and TV

Open Settings, go to the “Display” section.

Or immediately find the “Display” editing window in the Start menu.

Here you will see the display settings.

Select the display (or TV) you want to customize.

Each display will have its own set of settings.

The following groups of settings are presented:

  1. Display mode selection
  2. Selecting the Physical Location of Displays
  3. Selecting the Primary Display
  4. Customization of orientation, resolution, scaling, refresh rate of individual displays.

How to set the Primary monitor

By default, the Primary monitor shows the Top bar, Activities, and desktop shortcuts (if you have created them). You can change the monitor that will be considered the primary monitor, i.e. select a new primary monitor. For this:

1. Open the Settings app, go to the “Display” section.

2. In the Primary Display drop-down list, select the monitor that you want to make the primary.

3. Click the “Apply” button.

How to turn off the display or TV in the settings, without physically disconnecting

You can disconnect the HDMI cable from your TV or computer at any time, but this is not always convenient. In addition, you may want to turn off the computer monitor or the laptop's built-in monitor.

To turn off any monitor or TV in settings, open “Display” settings.

Select “Single Display” mode.

Then select the monitor you want to keep active (all others will be disabled).

Click the “Apply” button.

A disabled monitor will stop working (it will no longer receive a signal), but the disabled monitor will still be available in the settings. You can turn it back on at any time.

How to enable a display disabled in settings

Open the “Display” settings.

Select “Join Displays” or “Mirror” mode.

Click the “Apply” button.

This will automatically enable disabled monitors.

How to make the TV show the same thing as the monitor

Go to Setting → Display.

Select the “Mirror” option.

Click the “Apply” button.

As a result, the resulting settings for both monitors at once will be shown.

Now the output on the monitor and TV is the same:

You may notice that the picture is slightly cropped on the TV, this is due to the fact that the aspect ratio of the monitor built into the laptop and the TV is slightly different.

You can choose a different screen resolution and aspect ratio in the “Resolution” setting.

As a result, now the image on the TV is not cropped, but on the laptop monitor, blank bars appear on the sides of the screen.

How to make the TV become an extension of the monitor

Go to Setting → Display.

Select the “Join Displays” option.

In this case, one of the monitors will be considered the main one. In this case, each of the monitors will show its own desktop, which, in fact, is one.

Why can't I drag the program window to the second screen

If you see two displays in the settings, but you cannot drag the program window to the TV or the second display, then try dragging the window to the other side. That is, if you, for example, are trying to drag a program window to the left side, then try dragging it to the right side instead.

The fact is that the physical location of the second monitor (TV) and its location in the settings can be different. To fix this, swap the monitors in the settings.

In addition to the location of the monitors to the left and right of each other, other options are possible.

You can place one of the monitors (or TVs) above the other.

In this case, the screen resolution and desktop area will change accordingly.

If you have many monitors, you can place them however you want, not all monitors need to be in a straight line horizontally. You can arrange them, for example, as 3×2, that is, two rows of 3 monitors.

How to make the taskbar (Top bar) show on all monitors

If you want the Top bar (taskbar) to be shown on all connected monitors and TVs, then follow these steps.

Go to Setting → Appearance, in the “Dock” section, find the setting with the “Show on” drop-down list.

The following options will be offered:

  • All displays
  • Primary display
  • Built-in display
  • [List of connected monitors and TVs]

Select the “All displays” setting.

After that, the Taskbar will be shown on all monitors.

In this case, if the program window is opened using the Taskbar (Favorites), the program will appear on the monitor on which the Taskbar is located, the button of which was clicked.

The following video shows Ubuntu with a TV connected. The Ubuntu setting is set to “Join Displays” mode (combining displays), as well as showing the Taskbar on all monitors. The result shows an example of opening application windows on the TV and monitor and working in these applications.

Why is the sound played through a computer (laptop) and not through a TV

An HDMI cable can carry both video and audio. But even after connecting the TV with an HDMI cable, the sound is still output from the laptop speakers or computer speakers.

To change the audio output source, go to the audio settings. This can be done via Setting → Sound.

Or find this settings window through the start menu.

Find the “Output Device” setting.

Select the HDMI device from the dropdown list.

Why did the sound disappear after turning off the TV on the laptop (computer)

To change the audio output source, go to the audio settings. This can be done via Setting → Sound.

Or find this settings window through the start menu.

Find the “Output Device” setting.

In the drop-down list, select the “Speakers - Built-in Audio” device.

How to connect a TV to a computer in Linux in Xfce (Kali Linux, Xubuntu)

Is it possible to connect a TV or a second monitor to a computer in Linux

This post will show you how to connect a TV or a second monitor to a Linux computer with the Xfce desktop environment. It will also talk about the available settings and solutions to typical problems that arise when connecting a TV to a computer.

Xfce is used in distributions such as Kali Linux and Xubuntu, and the Xfce desktop environment can be installed on any other distribution.

If you have a different desktop environment, then see the articles:

If you are a Windows user, then see the article “How to connect a TV to a computer in Windows 11”.

What you need to connect a TV or an additional monitor to a computer

To connect a TV or a second monitor to a computer or laptop, you need:

  • TV with HDMI connector (all modern models) or monitor with HDMI connector (all monitors released in the last two decades)
  • a computer with an HDMI connector – almost all computers and laptops will fit
  • HDMI cable

Choosing an HDMI cable

I approached the choice of HDMI cable quite simply – I chose the cheapest with the right length, which I found in the store. In subsequent use, this cable fully satisfied my needs.

Despite its cheapness, this HDMI cable supports:

  • UHD 4K@2160P / 4K@60Hz / 4K HDR
  • High Speed HDMI 2.0
  • Gold plated contacts

Cable length 1.8 meters.

Apparently, these are already the minimum characteristics – perhaps more expensive models support higher resolutions and data transfer at higher speeds.

What TV can be connected to a computer

Using an HDMI cable, you can connect any TV with an HDMI connector. This connector is present on all TVs and monitors released in the last decade.

Older TVs without an HDMI connector can also be connected to a computer, but instead of an HDMI cable, you will need a wire with an adapter.

As for the technical characteristics of the TV (diagonal size, screen resolution, screen refresh rate, aspect ratio), this is not critical. That is, you do not have to select a TV model with the same characteristics as your monitor. Modern video cards support a variety of modes (screen resolutions and refresh rates), including the video card will work with a TV if the screen resolution is different from the monitor.

For example, the characteristics of my devices:

  • laptop monitor: 17", 1920×1080, 16:9, 120 Hz
  • TV (all specifications): 32", 1366x768p, 16:10, 60Hz

That is, these are two very different devices, but at the same time I had no problems when they worked together.

How to connect HDMI cable to TV

Plug the HDMI cable into the connectors of the computer (laptop) and TV.

Both on the computer and on the TV, there may be several HDMI connectors – remember the number of the selected connector.

Turn on your computer and TV.

Note: The HDMI cable can be connected when the computer and TV are already on.

Use the remote control to select “HDMI” as the input source on the TV.

If, after selecting HDMI as the signal source on the TV, you see the message “No Input Signal”, then:

  1. Select HDMI with a different number.
  2. Move the wire, it may not be firmly connected to the computer or TV socket.
  3. Make sure your computer is on.
  4. The monitor on the computer should not be turned off due to inactivity.

How to use a TV connected to a computer

There are two main modes:

  • join displays
  • mirror (duplication) of images on both displays

When displays are combined, the total space expands. That is, if you connected another 1920×1080 display to a computer with one 1920×1080 display, then now the resolution of your virtual screen becomes 3840×1080, if there are three such displays, the resolution will become 5760×1080. You can drag program windows from one display to another. Some apps and games support these wide virtual screens.

When the image is repeated (Mirror), the same image will be shown on both displays.

Among the displays, Primary stands out. This is the one connected first. A feature of the main display is that it shows desktop shortcuts, although this can be changed in the settings.

In the next video, the TV is connected to the computer. To play a YouTube video on a TV, the web browser window is dragged from the monitor to the TV. The video begins by selecting HDMI as the audio output source to play audio on a TV instead of playing it on a computer (laptop).

Where are the settings for the second display and TV

Open Settings (Setting Manager), go to the “Display” section.

Or immediately find the “Display” settings window in the Start menu.

Here you will see the display settings.

Select the display (or TV) you want to customize.

Each display will have its own set of settings.

How to install the Primary monitor

By default, desktop shortcuts are shown on the Primary monitor. You can change, i.e. choose a new primary monitor. For this:

1. Open the Settings Manager app, go to the “Display” section.

2. Select the monitor you want to make your primary

3. Activate the “Primary Display” slider next to the monitor name.

How to turn off the display or TV in the settings, without physically disconnecting

You can disconnect the HDMI cable from your TV or computer at any time, but this is not always convenient. In addition, you may want to turn off the computer monitor or the laptop's built-in monitor.

To turn off any monitor or TV in settings, open “Display” settings.

Select the monitor you want to turn off – this can be done by clicking on the schematic image of the monitor with a number or by selecting the name of the monitor from the drop-down list.

Then turn off the monitor using the slider marked 2 in the screenshot.

A disabled monitor will stop working (it will no longer receive an input signal), but the disabled monitor will still be available in the settings. You can turn it back on at any time.

How to make the TV show the same thing as the monitor

Go to Setting Manager → Display.

Select the “Mirror displays” option.

You may notice that the display sizes are not the same – this is due to the fact that they have different screen resolutions.

To ensure that the image is exactly the same on both displays, select the same screen resolution.

Please note that when “Mirror displays” is selected, the "Primary Display" option becomes unavailable because both monitors become equal.

As a result, the resulting settings for both monitors at once will be shown.

Now the image on the monitor and TV is the same:

How to make the TV become an extension of the monitor

Go to Setting Manager → Display.

Disable the “Mirror displays” option.

In this case, one of the monitors will be considered the main one. In this case, each of the monitors will show its own desktop, which, in fact, is one.

Why can't I drag the program window to the second screen

If you see two displays in the settings, but you can’t drag the program window to the TV or the second display, then try dragging the window to the other side. That is, if you, for example, are trying to drag a program window to the left side, then try dragging it to the right side instead.

The fact is that the physical location of the second monitor (TV) and its location in the settings can be different. To fix this, swap the monitors in the settings:

In addition to the location of the monitors to the left and right of each other, other options are possible.

You can place one of the monitors (or TVs) above the other.

In this case, the screen resolution and desktop area will change accordingly.

If you have many monitors, you can place them however you want, not all monitors need to be in a straight line horizontally. You can arrange them, for example, as 3×2, that is, two rows of 3 monitors.

After changing the relative position of monitors in the settings, shortcuts and the taskbar moved to another monitor

If you swapped them in the monitor settings, then the desktop shortcuts and the taskbar are most likely moved to the leftmost monitor (TV). This is due to the fact that by default it is set in the settings that the Desktop shortcuts and the Panel are placed automatically, without being tied to the Primary display. How to make the Desktop shortcuts and Panel show on the Primary monitor is shown below.

Customizing the Xfce Panel, Desktop shortcuts and Notifications on a computer with multiple monitors

Options related to advanced settings for your TV or second monitor are located in the following settings sections:

  • Panel
  • Desktop
  • Notifications

All of these settings can be quickly accessed at once by going to Setting Manager → Display and then clicking the letter “i” next to the “Primary Display” enable slider.

You will see the following window:

The primary display is currently configured to show

  • Xfce Panel
  • Desktop icons
  • Notifications

In this window, you can click the “Configure” buttons next to the setting you want to change.

How to make the taskbar show on the main monitor

Go to Setting Manager → Display, click the “i” next to the “Primary Display” slider.

Opposite “Xfce Panel” click the “Configure” button.

On the “Display” tab, find the “Output” setting.

Several options will be offered:

  • Automatic (that is, on the very first (left) monitor in the settings)
  • Primary (on the main monitor)
  • HDMI-1 (monitor connected via HDMI cable)
  • ePD-1 (laptop built-in monitor)

To show the taskbar on the main monitor, select the “Primary” option.

How to make the taskbar show on all monitors

If you want the taskbar to be shown on all connected monitors and TVs, then follow these steps.

Go to Setting Manager → Display, click the “i” next to the “Primary Display” slider.

Opposite “Xfce Panel” click the “Configure” button.

On the “Display” tab, find and activate the “Span monitors” setting.

After that, the Taskbar will be shown on all monitors. Open programs will be added to the taskbar from left to right. That is, at first the taskbar will be filled on the very first (left) monitor and then it will start to fill on the subsequent ones.

How to set different desktop wallpapers for monitor and TV

You can set a different desktop wallpaper for all connected monitors and TVs.

To do this, go to Setting Manager → Display, click the letter “i” next to the “Primary Display” enable slider.

Opposite “Desktop icons” click the “Configure” button.

You will see something like this:

Move this dialog to the display you want to edit the settings for

That is, in order to change the desktop wallpaper, you need to move the window that opens to the monitor (or TV) for which you want to set a new wallpaper.

For example, the inscription “Wallpaper for Monitor 0 (eDP-1)” means that the wallpaper will be set for the monitor built into the laptop.

And the inscription “Wallpaper for Monitor 1 (HDMI-1)” means that the wallpaper for the device connected via HDMI cable is currently being configured.

How to make Desktop icons show on Primary monitor

By default, desktop icons will be shown on the first (leftmost) monitor or TV. To change this, go to Setting Manager → Display, click on the letter “i” next to the “Primary Display” enable slider.

Opposite “Desktop icons” click the “Configure” button.

In the “Desktop” window that opens, go to the “Icons” tab.

Find and activate the “Show icons on primary display” setting.

How to make notifications appear on the Primary display

By default, notifications are shown on the display where the mouse cursor is when the notification is displayed. To change this, go to Setting Manager → Display, click on the letter “i” next to the “Primary Display” enable slider.

Opposite “Notifications”, click the “Configure” button.

In the window that opens, on the “General” tab, find the “Show notification on” setting and select “primary display” in the drop-down list.

How to make notifications appear on the display with the mouse pointer

Go to Setting Manager → Display, click the “i” next to the “Primary Display” slider.

Opposite “Notifications”, click the “Configure” button.

In the window that opens, on the “General” tab, find the “Show notification on” setting and select “display with mouse pointer” in the drop-down list.

Why are monitors of different sizes in the settings

If monitors have different screen resolutions, they will be shown in different sizes in the settings.

If you wish, you can choose the same screen resolutions for all monitors and TVs.

The same screen resolutions can be set both in the “Mirror displays” mode, and when using monitors to show different areas of the desktop.

Is it necessary to set the same resolution for the monitor and TV

No, it doesn’t need.

Moreover, the TV or monitor may not support the resolution or screen refresh rate that the second monitor supports.

For example, if you have selected a screen resolution of 1920×1080 in the TV settings, but the TV itself only supports 1366×768, then the picture will be displayed with a resolution of 1366×768 anyway.

How to make the monitor display popup windows to identify displays

If you have multiple monitors and you are confused about their settings, then you can enable the display of the name and number on the screen of each monitor.

Go to Setting Manager → Display, open the “Advanced” tab.

Activate the setting “Identifying Displays. Show popup windows to identify displays”.

How to remove pop-up windows with monitor names and numbers

Go to Setting Manager → Display, open the “Advanced” tab.

Disable the “Show popup windows to identify displays” setting.

How to enable automatic configuration of connected displays

Go to Setting Manager → Display, open the “Advanced” tab.

Activate the “Configure new displays when connected” setting.

How to turn off automatic configuration of connected displays

Go to Setting Manager → Display, open the “Advanced” tab.

Disable the “Configure new displays when connected” setting.

Why is the sound played through a computer (laptop) and not through a TV

An HDMI cable can carry both video and audio. But even after connecting the TV with an HDMI cable, sound is still output from the laptop speakers or computer speakers.

To change the sound output source, go to the sound settings (Volume Control). This can be done via Setting Manager → PulseAudio Volume Control.

Or find this settings window through the start menu.

Another quick way to get to the sound settings is to click on the speaker icon next to the clock and select “Audio mixer”.

The “Output Devices” tab will open, you can search there for a TV or HDMI device as an audio output source, but in my case there was no such device. Only “Speakers” were available as “Port”.

To switch the sound output to an HDMI device, go to the “Configuration” tab and in the drop-down list of the “Profile” setting, select the item with HDMI.

For example, to get the sound through the TV, I chose “Digital Stereo (HDMI) Output” instead of “Analog Stereo Output”.

Why did the sound disappear after turning off the TV on the laptop (computer)

To change the sound output source, go to the sound settings (Volume Control). This can be done through Setting Manager → PulseAudio Volume Control, or find this settings window through the start menu. Another quick way to get to the sound settings is to click on the speaker icon next to the clock and select “Audio mixer”.

Go to the “Configuration” tab and in the drop-down list of the “Profile” setting, select “Analog Stereo Output”.

Setting the action when closing the laptop lid when using a second monitor

If you are using a laptop, closing the laptop lid when additional monitors are connected to it may not be what you expect. For example, when you close the laptop lid, the computer goes into Suspend (Sleep) mode or shuts down, and you expect to be able to work on a second monitor or watch TV connected to the computer.

To control how the computer behaves when the laptop lid is closed, go to Settings Manager → Power Management.

You can also find this settings window through the Start menu.

Here in the “System” tab you can change the behavior performed when the laptop lid is closed.

Please note that the behavior of the computer in two modes is separately configured:

  • On battery – when the laptop is running on battery power
  • Plugged in – when the laptop is running on mains power

The “When laptop lid is closed” setting determines the action that the computer will perform when the laptop lid is closed, even if a second monitor or TV is connected to it.

The following options are available:

  • Switch off display – disable built-in laptop display
  • Suspend – Stops all applications and puts the computer into low power mode. When you turn on the computer, it returns to the same state that it was before Suspend. The difference from Hibernate is that the computer turns on faster, although it continues to consume energy.
  • Hibernate – hibernation mode, writing the current state of the computer and RAM to the hard disk and turning off the computer. When you turn on the computer, it returns to the same state that it was before Hibernate. The difference from Suspend is that the computer completely stops consuming power and cannot lose data due to the fact that the battery is dead. But it turns on a little longer than when exiting the Suspend state.
  • Lock screen – Show a screensaver that requires the user to enter a password.

If you do not want the laptop to turn off when the lid is closed, then select “Switch off display” or “Lock screen”.

Loading...
X