Adding a legend to a map

This trick add the legend to a map in a specific positon

composite -gravity southeast -geometry +10+10 leyenda.png mapa_sin.png mapa_con.png
more ...

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 ...

Split an A3 in 4 A4

A trick for splitting an A3 in 4 A4

pdftk mapA3.pdf burst output pgmapa3%d.pdf
convert -density 600x600 -limit memory 32 pgmapa31.pdf pgmapa31.jpg
convert -verbose -crop 3508x4960 pgmapa31.jpg pgmapa31_%02d.jpg
convert -page A4 -resize '2480x3508^>' -extent 2620x3706 pgmapa31_0* pgmapa4.pdf
gs -sDEVICE=pdfwrite -dNOPAUSE ...
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 ...