Thursday, November 05, 2026

Linux CLI - more notes to self

[NOTE: As I've encountered some interesting challenges I'm adding to this list and will update the format a bit from the first post. Last modified - 5 November 2026 - added Linux CLI Imagemagick running on Android]

Android Imagemagick Install and Use -

To run the Imagemagick CLI on Android requires a Linux terminal emulation -

  • PlayStore search "termux"
  • Install "termux"
  • Open "termux" app 

Now we need to add directory access to "termux", so run (where $ is simply the prompt) -

  • $ termux-setup-storage 

To find, install, configure Imagemagick, run -

  • $ pkg update 
  • $ pkg upgrade
  • $ pkg search imagemagick
  • $ pkg install imagemagick

To confirm image magic is installed and contains the support desired, run -

  • $ which magick
  • $ magick -help
  • $ magick -version

To confirm the Android file system is mounted and accessible, run something like -

  • $ ls storage <- this will show which directories "termux" can see
  • $ ls storage/dcim <-example of getting into the camera file system on the device

To work with Imagemagick, using a file manager app on Android, create a directory that is accessible to "termux" and organize subfolders in whatever way makes sense for manipulating image files using "magick".  For instance -

  • Using an Android running file manager, in the ../dcim directory, make a new directory and label it to something meaningful, then...
  • Returning to the "termux" Linux terminal emulation, do something like the following -
    • $ cd storage
    • $ cd dcim
    • $ cd <directory created for image manipulation purposes>
    • ... or simply/more directly...
    • $ cd storage/dcim/<directory created for image manipulation purposes>

From the working directory you can now run any Imagemagick command you like on the files deliberately loaded into the  <directory created for image manipulation purposes>  

Any of the Imagemagick commands in the following (original) section may be executed with the expected results.  Even bash commands are executable with Imagemagick commands embedded. 

Linux Command Line Interface - 

ImageMagick has evolved and some of the commands I've used in the past are now deprecated.  So, here's an update in a new post (keeping the old post as reference).

magick some_image.png Hald_CLUT_x.png -hald-clut result_image.jpg - Takes a base image and applies a 4k by 4k LUT from the command line, requires Imagemagick v7+.  Built by hand on MintOS Linux as this version isn't yet available from a software repository.  

For some reason when installing a new version of Linux the imagemagic ./config... showed no jpg support.  A sudo apt-get install libjpeg-dev command was required.  Similarly, libpng-dev, libtiff-dev and other image file formats seem to be missing and need to be included. 

With magick we can use a Bash script to CLUT sample colorize a batch of images as follows...

for i in *.jpg; do magick "$i" -colorspace Gray  "BW_$i"; done – Bash script to convert a bunch of files into black and white updated from depricated "convert" command

for i in *.JPG; do magick "$i" Hald_CLUT_4kx4k.png -hald-clut "Tinted$i"; done - Takes a HaldCLUT and applies colors/tints to multiple files while renaming the output so as to not collide with the original images

magick -background transparent *.JPG -resize "1600x1600>" -gravity center -extent 2000x2000 -evaluate-sequence mean averaged_image_output.jpg - Image averaging command where the frame size is set by -extent and input files are -resized as specified

magick -background transparent *.JPG -rotate "90>"  -resize "1600x1600>" -gravity center -extent 2000x2000 -evaluate-sequence mean averaged_image_output.jpg - Same as above, except this rotates images to align horizontal and vertical.

magick -background transparent *.JPG -gravity center -evaluate-sequence mean -level x%,xx% -sigmoidal-contrast y,yy% outputfilename.jpg - Resizing nothing and taking the image files as they come, no reorientation, "-level" added where the first number pulled the black level to the right and the second number sets the white level.  Added "-sidmoidal-contrast" that adds an "S shaped contrast curve" where the first number is also the moving of the black level to the right and the second number defines the steepness of the contrast curve.

for i in {0..xxxx..x00}; do magick "inputfilename.jpg" -crop Xdimension_x_Ydimension+0+$i +repage "OutputFilename$i.jpg"; done - A bash script to sectional slice an image file 

mogrify -format jpg *.png - change file format from png to jpg

mogrify -resize 1920 *.jpg – resizing command

mogrify -bordercolor black -border 10x10 *.jpg – adding a thin black edge to images

mogrify -bordercolor white -border 400x400 *.jpg – adding a white border to images

for i in *.jpg; do convert "$i" -colorspace Gray  "BW_$i"; done – Bash script to convert a bunch of files into black and white

------- not Imagemagick, but still available on Android  using "termux" ------- 

Following the "termux" installation found above, run the following -

  • $ pkg search gmic
  • $ pkg install gmic  

Verify gmic is correctly installed by running -

  • $ which gmic
  • $ gmic -help <- Caution:Will likely scroll forever, or so it'll seem, its really long
  • $ gmic -version

gmic -input <filename.file-extension> scale_dcci2x , cut 0,255 round output <theOutputFileName>.<fileExtension> - command to perform a DCCI2x upsize - on Linux or Android "termux", where <fileExtension> can be ".tif"

--------------- not Imagemagick commands -------------------

exiftool -a -u -s -G1 <file_name> - to read EXIF image file data

LibreOffice : Impress

  • menu Insert | Media | Photo Album :: Slide Layout 

 

Italian Meeting Montlhery ~ 2026 (BW) 

------------- pre IMv7 commands ---------------

convert -background transparent *.JPG -resize "1600x1600>" -gravity center -extent 2000x2000 -evaluate-sequence mean averaged_image_output.jpg - From before the deprication which means pre-v7 versions of Imagemagick -Image averaging command where the frame size is set by -extent and input files are -resized as specified

convert *.jpg -average <averaged-filename>.jpg – averaging command

convert *.jpg -evaluate-sequence median <output file-name>.jpg  - a different averaging command

convert <filename>.<file-extension> -colorspace gray <output filename>.<file-extension> – command to convert a single image to black and white