Adding margins to an image to match a A4 pdf

Adding margins for a A4 pdf

convert montado000.jpg -bordercolor white -border 70 -page A4 salida.pdf

Take into account that the order of the parameters is important and -bordercolor should appear before of -border or everything will be grey.

more ...

Crop an imagen

Convert can be used to crop images

#!/bin/bash

mkdir cropped;
for i in `ls *.png`;
do convert -verbose -crop 1176x880+502+144 $i ./cropped/$i;
done;
echo FIN;
1176x880
is the final size of the image
+502+144
is the upper left corner where the cropping starts
more ...

Get a colour histogram from an image

You can get an histogram of the colours used in an image

convert RASTER2.jpg -format %c histogram:info:-
format
will return caracteristic information
%c
will return also the comments from the command
histogram
for getting the histogram
info
for getting additional info
-
the output will be via cli, it ...
more ...

Preparing a set of counters

Adding a border to the image

convert -bordercolor black -border 2 image_sin.png image_con.png

Turn the counter and adding a 5 pixel blue band

convert -rotate 180 -gravity north -background blue -splice 0x5 contadorA.png contadorA_r.png

Mounting the 2 images as a single one

montage -tile x2 -geometry ...
more ...

Resizing of images

For images resizing

#!/bin/bash

mkdir 640x480;
for i in `ls *.png`;
do convert -verbose -quality 65 -strip -resize 640x480 $i ./640x480/$i;
done;
echo FIN;
65
is the final quality (%)
640x480
is the final size. The image will be resized to meet one of the two dimensions but respecting ...
more ...


Transforming GIF to PNG

You can conver a GIF into a series of PNGs

convert * .gif -transparent white name-%d.png
  • it will convert all the gifs
  • asigns white as the transparency color
  • the output files will be named like name-01.png ...
more ...