Scripted drawing with ImageMagick Silhouette
Linux Magazine|#263/Ocober 2022: Build an IoT Linux
ImageMagick can do more than just edit existing images. The free software can even be scripted to create simple drawings.
RALF KIRSCHNER
Scripted drawing with ImageMagick Silhouette

Although you would normally use a bona fide graphics program for drawing and painting, there are definitely situations in which you need to draw regular shapes in an image repeatedly at fixed intervals – as shown here, for example, when creating the silhouette of an imaginary city (Figure 1). This does not require an expensive graphics program with a sophisticated macro language. Using the free and open source ImageMagick software package at the command line is more than up to this task.

To compose more extensive images, you will need the support of a scripting language such as Bash, which uses loops and other control structures to repeatedly insert image content into the graphic. ImageMagick can be found in the package sources of most Linux distributions, but it can also be downloaded for installation from the download section of the project page [1].

magick logo: logo.gif

Painting by Commands

After completing the install, type at the command line. ImageMagick will create the logo.gif file in the current directory. It shows the magician seen in the upper right corner of Figure 1. You can easily check this by opening the file in a suitable image viewer. Image names ending with a colon are internal test images in ImageMagick. You can create more test images with the rose: and wizard: [2] options.

To demonstrate that you can actually draw at the command line with ImageMagick, see the command in Listing 1.

Listing 1: Rectangle

Esta historia es de la edición #263/Ocober 2022: Build an IoT Linux de Linux Magazine.

Comience su prueba gratuita de Magzter GOLD de 7 días para acceder a miles de historias premium seleccionadas y a más de 9,000 revistas y periódicos.

Esta historia es de la edición #263/Ocober 2022: Build an IoT Linux de Linux Magazine.

Comience su prueba gratuita de Magzter GOLD de 7 días para acceder a miles de historias premium seleccionadas y a más de 9,000 revistas y periódicos.

MÁS HISTORIAS DE LINUX MAGAZINEVer todo
MADDOG'S DOGHOUSE
Linux Magazine

MADDOG'S DOGHOUSE

The stakeholder approach of open source broadens the pool of who can access, influence, and benefit from information technologies.

time-read
3 minutos  |
#289/December 2024: Coding with AI
MakerSpace
Linux Magazine

MakerSpace

Rust, a potential successor to C/C++, claims to solve some memory safety issues while maintaining high performance. We look at Rust on embedded systems, where memory safety, concurrency, and security are equally important

time-read
10+ minutos  |
#289/December 2024: Coding with AI
In Harmony
Linux Magazine

In Harmony

Using the Go Interface mechanism, Mike demonstrates its practical application with a refresh program for local copies of Git repositories.

time-read
9 minutos  |
#289/December 2024: Coding with AI
Monkey Business
Linux Magazine

Monkey Business

Even small changes in a web page can improve the browsing experience. Your preferred web browser provides all the tools you need to inject JavaScript to adapt the page. You just need a browser with its debugging tools, some knowledge of scripting, and the browser extension Tampermonkey.

time-read
10+ minutos  |
#289/December 2024: Coding with AI
Smarter Navigation
Linux Magazine

Smarter Navigation

Zoxide, a modern version of cd, lets you navigate long directory paths with less typing.

time-read
4 minutos  |
#289/December 2024: Coding with AI
Through the Back Door
Linux Magazine

Through the Back Door

Cybercriminals are increasingly discovering Linux and adapting malware previously designed for Windows systems. We take you inside the Linux version of a famous Windows ransomware tool.

time-read
9 minutos  |
#289/December 2024: Coding with AI
Page Pulse
Linux Magazine

Page Pulse

Do you want to be alerted when a product is back in stock on your favorite online store? Do you want to know when a website without an RSS feed gets an update? With changedetection.io, you can stay up-to-date on website changes.

time-read
8 minutos  |
#289/December 2024: Coding with AI
Arco Linux
Linux Magazine

Arco Linux

ArcoLinux, an Arch derivative, offers easier installs while educating users about Arch Linux along the way.

time-read
5 minutos  |
#289/December 2024: Coding with AI
Ghost Coder
Linux Magazine

Ghost Coder

Artificial intelligence is increasingly supporting programmers in their daily work. How effective are these tools? What are the dangers? And how can you benefit from Al-assisted development today?

time-read
10+ minutos  |
#289/December 2024: Coding with AI
Zack's Kernel News
Linux Magazine

Zack's Kernel News

Chronicler Zack Brown reports on the latest news, views, dilemmas, and developments within the Linux kernel community.

time-read
9 minutos  |
#289/December 2024: Coding with AI