From 太極
Jump to navigation Jump to search

File formats

Explaining Image File Formats (video)

Note we can compress files before we share them/upload to web servers.

Free images

StockAI Free AI-generated stock photos

Convert a color image to black and white/grayscale

$ convert filename.jpg -canny 0x1 -negate canny.jpg
convert.im6: unrecognized option `-canny' @ error/convert.c/ConvertImageCommand/1107.

$ convert filename.jpg +clone +level-colors gray,white -background black -alpha remove -colorspace Gray canny.jpg

$ convert filename.jpg -monochrome canny.jpg

$ convert filename.jpg -colorspace Gray canny.jpg  # Best

The current imagemagick version is 7.0.7-15.


Convert and Manipulate Images With ‘Converter’ GUI Tool in Linux

Free-to-Use Image-Editing Apps for Linux

The Top 9 Free-to-Use Image-Editing Apps for Linux

Install/build the latest imagemagick

# remove version installed with apt-get
sudo apt-get remove imagemagick && sudo apt-get autoremove

# install dependencies
sudo apt-get install build-essential
sudo apt-get build-dep imagemagick -y

# download ImageMagick source
tar xzvf ImageMagick.tar.gz

# build source
cd ImageMagick-*

# install and verify
sudo make install
sudo ldconfig /usr/local/lib

sudo checkinstall


 Done. The new package has been installed and saved to


 You can remove it from your system anytime using: 

      dpkg -r imagemagick-7.0.7


$ convert --version
# bash: /usr/bin/convert: No such file or directory

$ which convert
$ whereis convert
convert: /usr/local/bin/convert
$ /usr/local/bin/convert -version
Version: ImageMagick 7.0.7-15 Q16 x86_64 2017-12-20
Copyright: © 1999-2018 ImageMagick Studio LLC
Features: Cipher DPC HDRI OpenMP 
Delegates (built-in): bzlib fontconfig freetype jbig jng jpeg lzma pangocairo png tiff x xml zlib

Convert an image to sketch (online tool)

convert my-image.jpg -colorspace Gray my-image-gray.jpg
# OR
convert <img_in> -set colorspace Gray -separate -average <img_out>

To convert into a 2-bit image

convert my-image.jpg -colorspace Gray -depth 2 my-image-gray.jpg 

Create sprite/pixel art

Convert an image to a different resolution/pixel size

A few basic (but powerful) ImageMagick commands

convert image.jpg -resize 1024x768\! output_file.jpg

Anti-alias 修邊

Upscayl: AI Image Upscaler Upscayl helps you turn low resolution images into high resolution. Crisp and sharp! No internet required. 5+ Modes. Fully Customizable. Free and Open Source.

Convert an image file to a different format (eg icon)

Make an icon using GIMP

How to Make an Icon for Windows 10 or 11 Out of Any Image

Crop an image

Rotate an image

convert winamp-ncrow.png -rotate 45 winamp-ncrow2.png  # 45 degrees

One problem with this simple approach is the picture size (not image file) changed (become smaller) if the degree is not one of 90,180 or 270.

Create an animated gif file

Use the script here. See the last example on here. The rotation speed looks good too! Just change the source image file in the script.

# Create a rotating figure using Distort SRT transformations
command='convert -delay 10 koala.gif -virtual-pixel white'

for i in `seq 5 5 360`; do
  command="$command \\( -clone 0 -distort SRT $i \\)"

command="$command -delete 0 -loop 0 animate_distort_rot.gif"

eval $command

chmod 644 animate_distort_rot.gif

Tool to convert a sequence of numbered PNG files to an animated GIF?. Convert command line option. The option '-loop 0' means repeats infinitely and '-delay 200' means 2 seconds delay between each frame.

convert -delay 200 -loop 0 file_1.png file_2.png file_3.png animated.gif

Combine/merge images

  • Combine 3 images into one row
    convert image1.png image2.png image3.png +append output.png
  • Combine 3 images into a 2x2 layout
    # Step 1
    convert image1.png image2.png +append row1.png
    convert image3.png null: +append row2.png
    # Step 2
    convert row1.png row2.png -append output.png

    The null: is used to create an empty space for the missing fourth image.

Creating a GIF from images/videos

The Best Ways to Make Your Own GIFs

Create a video from images

  • ffmpeg
    # frame rate of 24 frames per second, using the libx264 (h264) codec
    ffmpeg -framerate 24 -pattern_type glob -i '*.jpg' -c:v libx264 output.mp4
  • ImageMagick
    # The -delay option specifies the delay (50/100 = 0.5 seconds) between each frame, 
    # This means that the frame rate will be 1/0.5=2.
    # and -loop 0 makes the video loop indefinitely.
    # the default codec used for MP4 output is libx264
    convert -delay 50 -loop 0 *.jpg output.mp4
  • av
    # frame rate of 2 frames per second, using the libx264 (h264) codec
    av -r 2 -i *.jpg -c:v libx264 output.mp4
  • Mencoder
    # frame rate of 2 frames per second, using the MPEG-4 video codec (older than h264)
    mencoder "mf://*.jpg" -mf fps=2 -o output.mp4 -ovc lavc -lavcopts vcodec=mpeg4

Convert Video to GIF

The Best Ways to Convert Video to GIF

View images as Slideshow

HDR/High Dynamic Range

How to Create Fake High Dynamic Range Photos in Photoshop

R packages

Annotate jpeg/png file

See graphics::rasterImage()

Edit gif file

gifsicle package


Change white to transparent background

Set transparent background using ImageMagick and commandline prompt (it works)

convert test.png -transparent white transparent.png

Replace transparency in PNG images with white background

convert image.png -background white -alpha remove white.png

Adobe lightroom

Online tools to remove background

Automatic background removal using R

Image segmentation in R: Automatic background removal like in a Zoom conference

Remove unwanted objects

    • Download a video frame from YT. Open GIMP - New. Accept the default image size. Ctrl + v to paste the image from the clipboard. Choose "Image" -> "Crop to Content". Export to PNG.
    • I uploaded a png file. The saved file cannot be opened (Fatal error reading PNG image file: Not a PNG file). After I manually changed the extension to jpg and it works. The resolution of the saved image file is decreased however.
  • Lama Cleaner - A free and open-source inpainting tool powered by SOTA AI model
  • 切勿错过!终于在GitHub上找到10个超强悍的开源软件和免费项目! | 零度解说. Lama Cleaner, Misskey, StockAI, NBlog, AutoCut, Pake, Fyrox, Tooll 3, SMSBoom, Flarum.

Remove GPS metadata from jpg files - exiftool

sudo apt-get install libimage-exiftool-perl
exiftool -gps:all= -xmp:geotag= image.jpg

The image file will be updated. To check the current metadata, use

exiftool image.jpg | grep GPS

Note that the above command only remove gps information. The other information like date/time of creation, camera model are not changed.

Exitftool can also be used to edit the metadata on PDF files.

exiftool -Title="This is the Title" -Author="Happy Man" -Subject="PDF Metadata" drawing.pdf

An R package exifr also available on CRAN.


Error: Failed to get connection

inkscape -C --export-type=png input.svg --export-filename=output.png
# OR
inkscape -C  input.svg --export-filename=output.png

I got an error when I tested on headless system Either command works, however, in a desktop system.

So inkscape in a headless system is not possible!

Edit Svg image


MAKE MORE with Inkscape – Ink/Stitch

Animated gif


Photoshop alternatives

What’s the Difference between Illustrator and Photoshop

What’s the Difference between Illustrator and Photoshop?

Adobe InDesign vs. Illustrator

Adobe InDesign vs. Illustrator: Which One Should You Use?

Display images in a terminal

  • tiv/Terminal Image Viewer contains a mall C++ program. It works when I tested on a Ubuntu 22.04 box. I am using the commit version 7573de8 12/6/2023.
    git clone
    g++ --version
    cd TerminalImageViewer/src
    sudo make install
    tiv myimage.png


    File format is not rcognized. sudo apt install imagemagick solves the issue.

  • Using FIM



The 4 Best Websites to Create a Logo for Your Business


Recognize a doodling




How to Edit Photos on Your iPhone Using the Photos App: crop, change the aspect ratio of a photo, rotate a photo, make a mirror image of a photo, select frames from Live Photos, change a photo’s filter, Change the exposure, Adjust the brilliance, Adjust highlights, Adjust shadows, Create contrast, Brighten the photo, Enhance the colors (Adjust saturation, Adjust vibrancy)