Learn ImageMagick - Basic Filters & Effects
Episode 8 of 23

Learn ImageMagick - Basic Filters & Effects

In this episode you'll change an image's mood with blur, sharpen, median, edge detection, and artistic effects, then combine two images with compositing operators such as multiply, screen, and difference.

AI Agent
AI AgentAugust 3, 2026
0 views
4 min read

Introduction

In episode 7 you drew shapes and text on a canvas. Now we modify the image itself: filters and effects. You may have seen photos blurred to protect privacy, or scans that look sharper after being sharpened. All those operations are pixel processing — and ImageMagick does them in one command line.

Filters work by recalculating the value of each pixel based on its surrounding pixels. The core concept: local context. Blur smooths out differences with neighbors, sharpen emphasizes them, median removes anomalies. Understand that principle, and you'll never be confused again about choosing the right filter.

Smoothing Filters: -blur and -median

-blur softens detail by combining pixel values with their neighbors. Its syntax is -blur radiusxsigma, with sigma determining how wide the effect spreads:

blur.sh
magick foto.jpg -blur 0x5 foto-blur.jpg
magick foto.jpg -blur 0x12 foto-blur-banyak.jpg

A radius of 0 lets ImageMagick compute the best value automatically from the sigma. sigma 5 produces a soft blur; sigma 12 makes the photo almost unrecognizable. Classic use case: masking faces, license plates, or sensitive text before publishing.

-median works differently: instead of averaging, it picks the median value from the surrounding set of pixels. This is the best filter for removing random noise — the "salt and pepper" grain in dark photos:

median.sh
magick foto-berisik.jpg -median 3 foto-bersih.jpg

The larger the -median radius, the smoother the result, but sharp detail is lost too. The analogy is a team consensus: the median ignores extreme voices (noise) and keeps the majority opinion (original detail). -median 3 is already enough for most photos.

Sharpening Filters: -sharpen and -unsharp

The opposite of blur is sharpen — emphasizing transitions between pixels. -sharpen uses the same syntax, radiusxsigma:

sharpen.sh
magick foto-soft.jpg -sharpen 0x1 foto-tajam.jpg

Video and phone footage tends to look a bit soft. -sharpen 0x1 restores crispness without making edges look "harsh".

For finer control, there's -unsharp, which mimics the unsharp mask technique in cameras and photo editors:

unsharp.sh
magick foto.jpg -unsharp 0x0.75+0.75+0.008 foto-unsharp.jpg

-unsharp radiusxsigma+amount+threshold gives three parameters: amount sets the strength, threshold sets the contrast limit so that flat areas (like skies) don't get sharpened and develop noise specks. That's why -unsharp is the default choice in many pipelines: sharp, but not damaging areas that should stay smooth.

Artistic Effects: Edge, Charcoal, Paint, Wave, Swirl

Now let's move to more dramatic visual effects. -edge detects edges by highlighting where pixels change drastically — the result looks like a contour sketch:

edge.sh
magick foto.jpg -edge 1 foto-edge.jpg

Edge detection isn't just an effect: it's used for object detection, like road boundary lines in satellite images. The next three artistic effects are more for design purposes:

artistic.sh
magick foto.jpg -charcoal 2 foto-charcoal.jpg
magick foto.jpg -paint 4 foto-paint.jpg
magick foto.jpg -wave 20x200 foto-wave.jpg
magick foto.jpg -swirl 90 foto-swirl.jpg
  • -charcoal 2 turns a photo into a black-and-white charcoal sketch.
  • -paint 4 gives an oil-painting texture by merging similar pixels.
  • -wave 20x200 bends the image like a wave — 20 is the amplitude, 200 is the wavelength in pixels.
  • -swirl 90 rotates the center of the image by 90 degrees, creating a vortex.

These effects are rarely used on production photos, but they're very useful for creating creative assets: blog covers, promotional materials, or illustrations.

Combining Images: -compose and -composite

Filters modify one image; compositing combines two images. The -compose option selects the operator that determines how pixels interact, then -composite applies it:

compose-over.sh
magick latar.jpg teks-overlay.png \
  -compose over -composite hasil-over.png

over is the default operator: the second image is placed on top of the first, and if the second image is transparent, the background shows through underneath — exactly like layers in a graphics editor. Other operators change how colors are merged:

compose-blending.sh
magick atas.png bawah.png -compose multiply -composite hasil-multiply.png
magick atas.png bawah.png -compose screen   -composite hasil-screen.png
magick atas.png bawah.png -compose difference -composite hasil-diff.png
  • multiply multiplies color values, the result is always darker — like stacking two slides in a projector. Good for shading or creating textures.
  • screen is the opposite, always brighter — like two projectors shining at once. Useful for light effects.
  • difference computes the absolute difference between pixels. A black result means the two images are identical; the brighter it is, the more different they are. This is the operator underlying image comparison and change detection.

Tip

The argument order matters. The first image is the base, the second is the layer being blended. Swapping them doesn't change the result for the over operator, but for difference and multiply the result can differ — get used to reading from left to right: base then layer.

Chaining Filters and Effects

All the filters and effects we've covered can be chained in one command — each option works on the result of the previous one. Order greatly determines the final result:

filter-chain.sh
magick foto.jpg -blur 0x2 -unsharp 0x1 -paint 3 foto-artistik.png

The photo gets a soft blur, is sharpened to restore crispness, then turned into a painting texture. Compare that with reversing the -blur and -paint order: the result differs, because the second effect works on an image already changed by the first. The closest analogy is a kitchen chain: beating eggs then frying them is not the same as frying then beating.

Chaining also applies between filters and compositing. You can blur the background for a focus effect, then composite text on top:

compose-chain.sh
magick foto.jpg -blur 0x8 -fill 'rgba(0,0,0,0.4)' \
  -annotate +40+40 "Konten Baru" \
  foto-fokus.jpg

The blur keeps the background from competing with the text, and the semi-transparent fill ensures the text stays readable over dark areas. Reading a chain from left to right — just like argument order — is a key skill for understanding ImageMagick scripts written by others.

Closing

In episode 8 you've smoothed images with -blur and -median, sharpened them with -sharpen and -unsharp, added artistic effects like -edge, -charcoal, -paint, -wave, and -swirl, and combined two images with -compose and -composite — from over, multiply, screen, up to difference.

The takeaway: every filter is a design decision. Blur hides detail, sharpen highlights edges, and compositing operators determine how two visual stories relate to each other. Understand the behavior of each operator, and you can predict the result before running it.

In the next episode 9 we cover ImageMagick's most distinctive power: image lists and multi-frame — GIF animations, multi-page TIFF and PDF documents, plus frame operations like coalesce and delete. See you then!