Difference between revisions of "ImageMagick"

From Indie IT Wiki
 
(2 intermediate revisions by the same user not shown)
Line 28: Line 28:
  
 
  convert old.jpg -crop 67x67+130+0 +repage new.jpg
 
  convert old.jpg -crop 67x67+130+0 +repage new.jpg
 +
 +
Crop to a set size from the center of the image :-)
 +
 +
mogrify -quality 50 -format webp -resize 1280x -gravity center -crop 1280x710+0+0 -path optimised/ *.jpg
  
 
== HOWTO: Resize ==
 
== HOWTO: Resize ==
  
 
  convert FlexGet_NEW.png -resize 72x72^ FlexGet_NEWER.png
 
  convert FlexGet_NEW.png -resize 72x72^ FlexGet_NEWER.png
 +
 +
== HOWTO: Change Background ==
 +
 +
This will change a transparent background to white ...
 +
 +
convert image.png -quality 60 -background white -alpha remove -alpha off image.jpg
  
 
== HOWTO: Change Format ==
 
== HOWTO: Change Format ==
Line 37: Line 47:
 
Single file ...
 
Single file ...
  
  convert -quality 50 -format webp myimage.jpg
+
  convert -quality 50 -format webp image.jpg
  
 
All files in a folder ...
 
All files in a folder ...

Latest revision as of 10:32, 6 October 2024

HOWTO: Watermarking

#!/bin/bash

# Initialize variables
WM=/path/to/watermark.png
SCALE=50

# Find all image files in current directory and watermark
file -i * | grep image | awk -F':' '{ print $1 }' | while read IMAGE
  do
    echo Watermarking $IMAGE
    NAME=`echo $IMAGE | cut -f1 -d.`
    EXT=`echo $IMAGE | cut -f2 -d.`
    composite -dissolve 50% -gravity center -quality 100 \( $WM -resize $SCALE% \) "$IMAGE" "${NAME}_wm.${EXT}"
  done
exit 0

HOWTO: Resize And Change Quality

convert cover_big.jpg -resize 500x500 -quality 70 cover.jpg

HOWTO: Crop And Resize To 500x500

convert old.jpg -resize 500x500^ -gravity center -crop 500x500+0+0 +repage new.jpg

HOWTO: Crop

convert old.jpg -crop 67x67+130+0 +repage new.jpg

Crop to a set size from the center of the image :-)

mogrify -quality 50 -format webp -resize 1280x -gravity center -crop 1280x710+0+0 -path optimised/ *.jpg

HOWTO: Resize

convert FlexGet_NEW.png -resize 72x72^ FlexGet_NEWER.png

HOWTO: Change Background

This will change a transparent background to white ...

convert image.png -quality 60 -background white -alpha remove -alpha off image.jpg

HOWTO: Change Format

Single file ...

convert -quality 50 -format webp image.jpg

All files in a folder ...

mogrify -quality 50 -format webp *.jpg

HOWTO: Save In Different Folder

mkdir optimised
mogrify -quality 50 -format webp -resize 640x -path optimised/ *.jpg

HOWTO: Identify

identify FlexGet_NEWER.png

HOWTO: Display

display FlexGet_NEWER.png

Information

http://www.imagemagick.org