add imagemagick post

This commit is contained in:
lee2sman 2022-09-06 02:15:19 -04:00
parent 3f94685197
commit ee8e4d4806
3 changed files with 69 additions and 0 deletions

BIN
images/imagemagick.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -25,6 +25,8 @@ This gemlog is best visited between 1am and 6am local time.
# Posts
=> imagemagick.gmi 2022-09-06 - Basic image editing in the command line
=> trash.gmi 2022-08-07 - Trash rules everything around me
=> impressions-of-ubuntu.gmi 2022-08-05 - Short impressions of Lubuntu and Regolith Linux

67
magick.gmi Normal file
View File

@ -0,0 +1,67 @@
2022-09-06
# Basic photo editing recipes for the command line
When I started using Linux systems I was initially attracted to the free cost, its lineage of open source software, and the challenge and adventure of using new tools. I still like those things. But more and more I've come to realize that those feel closer to personal preferences than clear advantages. Sure, free is nice, but open source software is often maligned as kludgy - awkward interfaces, for example, or tools that don't quite work without fine tuning your system settings. To be fair, that does occasionally trip me up.
But one of the huge advantages of Linux that I've learned over time is the composability of commands in the command line. With a few terse words you can coax out powerful tools rather than the amount of time searching in GUI software. And more importantly, you can by its very CLI nature automate repetitive tasks, even complex ones.
For years now I've done the majority of my photo prepping and editing with ImageMagick in the command line.
> Use ImageMagick® to create, edit, compose, or convert digital images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, WebP, HEIC, SVG, PDF, DPX, EXR and TIFF. ImageMagick can resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.
What follows are some of the recipes I use for individual and mass editing photos.
### Basic image conversion
```
convert input.jpg output.png
```
### Convert and resize
```
convert input.jpg -resize 30% output.png
```
### Convert bulk images without making new files
This will take all images in the folder, resize them to 800x600, then convert them to png files
```
mogrify convert -resize 800x600 -format jpg *.png
```
### Dither
=> images/imagemagick.gif ImageMagick logo dithered
There are many dithering options available but here's a simple one I tend to use - it dithers and converts to grayscale.
```
convert input.jpg -resize 800x600 -colorspace gray -ordered-dither 8x8 output.gif
```
### Remove white background, convert images to png files
Bash script that loops through all png files in a folder, removing the white so there is a transparent background, and re-numbering all image files.
```
cnt=1
for file in *.png
do
convert $file -fuzz 20% -transparent white ${cnt}.png
cnt=$(( $cnt + 1 ))
done
```
## Links
=> https://imagemagick.org/Usage/ Example ImageMagick usage
=> http://www.fmwconcepts.com/imagemagick/lomography/index.php Fred's ImageMagick Scripts give hundreds of examples. Check out the lomography-effect script.
=> ./index.gmi Back to index
---
Leave a public comment by emailing lettuce at the current domain and putting comment in your subject. Please let me know what name you'd like to be listed.