What is ImageMagick
Many people thing that they need closed sources software to process photos, to create GIF animations, color management and transform images by sizing, croping and rotation.
ImageMagick can do more then what we expect. It can also read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, HEIC, TIFF, DPX, EXR, WebP, Postscript, PDF, and SVG.
ImageMagick is free and open source. It’s available in linux, mac and windows using MinGW .
It’s also available in lib format to make iOS, Windows, Linux Apps and as a php extension called “php7.x-imagick” to build server side image processing.
After installing ImageMagick you should have access to all its tools.
Identify
This tool is necessary to extract image information, specially with -verbose param this command will return all the information of the giving image. Here is an example:
identify -verbose beach-beautiful-bridge-449627.jpg
Image: beach-beautiful-bridge-449627.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 4032x3024+0+0
Resolution: 72x72
Print size: 56x42
Units: PixelsPerInch
Colorspace: sRGB
Type: TrueColor
Base type: Undefined
Endianess: Undefined
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Channel statistics:
Pixels: 12192768
Red:
min: 0 (0)
max: 255 (1)
mean: 70.7684 (0.277523)
standard deviation: 67.0167 (0.262811)
kurtosis: -0.402136
skewness: 0.753672
entropy: 0.888948
Green:
min: 0 (0)
max: 255 (1)
mean: 158.36 (0.62102)
standard deviation: 58.2885 (0.228582)
kurtosis: -0.658039
skewness: -0.602582
entropy: 0.962202
Blue:
min: 0 (0)
max: 255 (1)
mean: 209.097 (0.819987)
standard deviation: 62.8143 (0.246331)
kurtosis: 0.66187
skewness: -1.37573
entropy: 0.767422
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 146.075 (0.572843)
standard deviation: 62.7065 (0.245908)
kurtosis: -1.24161
skewness: -0.300494
entropy: 0.872858
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 4032x3024+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 73
Orientation: Undefined
Properties:
date:create: 2019-08-30T09:12:12+00:00
date:modify: 2019-05-03T13:10:37+00:00
icc:copyright: Copyright (c) 1998 Hewlett-Packard Company
icc:description: sRGB IEC61966-2.1
icc:manufacturer: IEC http://www.iec.ch
icc:model: IEC 61966-2.1 Default RGB colour space - sRGB
jpeg:colorspace: 2
jpeg:sampling-factor: 2x2,1x1,1x1
signature: 567a0413315a5c6d41a4323b956452b234470449c7244448b2362c73411a0b57
Profiles:
Profile-icc: 3144 bytes
Artifacts:
verbose: true
Tainted: False
Filesize: 2.42723MiB
Number pixels: 12.1928M
Pixels per second: 57.8762MP
User time: 0.200u
Elapsed time: 0:01.210
Version: ImageMagick 7.0.8-59 Q16 x86_64 2019-08-04 https://imagemagick.org
With this command line, we can extract colors, pixel, copyright and a lot of informations of a given image.
Inline Image resize
This is the most used command on server size when uploading a gallery. Imagine that you copied a RAW images from an SDCard and you want to resize all the images to a specific ratio. you can run this command when you are on the folder:
cd ~/Images mkdir folder magick '\*.jpg[widthxheight]' folder/%03d.jpg
Inline Image Crop
The same as resizing, croping need the X and Y to define witch part will start croping:
magick '\*.jpg' -crop widthxheight+x+y thumbnail%03d.jpg
Other Image processing commands
There are a lot of commands that correct gamma, alpha, filter, blur, … etc of a given image. These commands are available with convert and mogrify tools. There is also -auto-gamma, -auto-level, -auto-threshold that accepts Kapur and OTSU methods. You have to know that you must have a minimum knowledge of image processing fundamentals that help you making a good magick commands and treatments. All these commands are well documented and explained here https://imagemagick.org/script/command-line-options.php.
The name of these commands are the sameof the theory behind so you can learn about it if you want. Don’t forget that ImageMagick is Open Source and FREE so you can find the codes that makes these function available to you.
The post [ImageMagick] Useful commands to process images appeared first on C.Khalifa.
Top comments (0)