Skip to content

Commit

Permalink
Update 01.en.md
Browse files Browse the repository at this point in the history
  • Loading branch information
El-Karollo authored Oct 4, 2024
1 parent 6c50aa0 commit 7dc0338
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tutorials/viewing-and-editing-images-in-terminal/01.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ short_description: "In this tutorial I will tell how without leaving the termina
author: "Karol Sarbiewski"
author_link: "https://github.com/El-Karollo"
author_img: "https://avatars3.githubusercontent.com/u/167524708"
author_description: "Manipulating arrays of characters in modern text editors that need more RAM than we used to fly to the moon. But it's super awesome..."
language: "en"
available_languages: ["en"]
---
## Edit / preview images in the terminal
In this tutorial I will talk a little about images in the terminal. Probably everyone has had a problem at some point... when he was designing a page and wanted to see if a particular image was that particular image.... had to upload it to apache or download it. Or he wanted to make the image smaller or crop it. What if I tell you that it is possible to do all this from a terminal? Only two things are enough for this: the ``imagemagick`` library and the ``tiv`` program.

I will be using two images throughout this tutorial.
I will be using two images throughout this tutorial. <br>
![code.jpg](images/code.jpg) ![server.jpg](images/server.jpg)

### Installing packages
Expand Down Expand Up @@ -63,7 +62,7 @@ sudo zypper install ImageMagick
Once we have gone through the installation of all the required packages, we can start by installing the ``tiv`` tool - TerminalImageViewer. With it we will be able to preview the image without leaving the terminal window.

How does it work? The image that we point to ``tiv`` is divided into small segments. The color of these segments is averaged. Then these segments are displayed to us in the terminal as ▎▖ characters with previously taken colors. In practice, what comes out is a block of text that looks a bit like pixel-art. Below is a picture:
![image inside terminal - tiv](images/tiv-server.jpg)
![image inside terminal - tiv](images/tiv-server.jpg) <br>
As you can see in the image above - you can easily see what the graphic shows.

#### Installing TerminalImageViewer
Expand All @@ -84,23 +83,23 @@ To increase or decrease the size of an image by a given percentage we will use:
```bash
convert INPUT_IMAGE.jpg -resize XX% OUTPUT_IMAGE.jpg
```
In the place where ``XX%`` is, we specify the resize percentage. For example, ``50%`` or ``150%``.
In the place where ``XX%`` is, we specify the resize percentage. For example, ``50%`` or ``150%``. <br>
![server.jpg 50% smaller](images/server50prc_small.jpg)

#### Changing the image to a specific dimension
Here we will also use the -resize flag only we will give specific dimensions:
```bash
convert INPUT_IMAGE.jpg -resize WWWxHHH! OUTPUT_IMAGE.jpg
```
In the place of ``WWWxHHH!`` we specify the dimensions to which the image should be scaled. For example: ``100x120!`` or ``800x600!`` (remember the exclamation point at the end).
In the place of ``WWWxHHH!`` we specify the dimensions to which the image should be scaled. For example: ``100x120!`` or ``800x600!`` (remember the exclamation point at the end). <br>
![code.jpg with 200x100 size](images/code200x100.jpg)

#### Resize the image by specifying only one of the parameters
We can also in the -resize flag specify only one of the parameters (e.g. height) then the other parameter (e.g. width) will be calculated and the aspect ratio will be preserved.
```bash
convert INPUT_IMAGE.jpg -resize xHHH OUTPUT_IMAGE.jpg
```
In the place of ``xHHH`` we specify the height of the image so that the width is adjusted proportionally - for example: ``x500``. We can do it analogously with the height of the image - for example: ``200x``.
In the place of ``xHHH`` we specify the height of the image so that the width is adjusted proportionally - for example: ``x500``. We can do it analogously with the height of the image - for example: ``200x``. <br>
![server.jpg with 100px height](images/server_x100.jpg)

#### Adding a border around an image
Expand Down Expand Up @@ -130,7 +129,7 @@ To crop the image to the required dimension from a specific point in the image (
```bash
convert INPUT_IMAGE.jpg -crop WWxHH+XX+YY OUTPUT_IMAGE.jpg
```
In this command, as in the one above, we set the size of the crop using ``WWxHH``. In addition, the next parameters are ``+XX+YY``. These are the coordinates from which the image will be cropped - for example: ``+34+100``. The whole to complete in this command looks like this: ``100x150+34+100``.
In this command, as in the one above, we set the size of the crop using ``WWxHH``. In addition, the next parameters are ``+XX+YY``. These are the coordinates from which the image will be cropped - for example: ``+34+100``. The whole to complete in this command looks like this: ``100x150+34+100``. <br>
![code.jpg cropped to 100x150 x=34 y=100](images/code_100x150+34+100.jpg)

#### Invert X-axis image
Expand Down

0 comments on commit 7dc0338

Please sign in to comment.