I would like to add a logo to a map that I am printing with the PNG driver.
It is a .jpg, although I could switch it to another image type if that was
helpful. Is there any way to do that? I know I could add it in photoshop
after the fact, but it would be simpler if I could print it right onto the
map in one go.
I would like to add a logo to a map that I am printing with the PNG driver.
It is a .jpg, although I could switch it to another image type if that was
helpful. Is there any way to do that?
Import it as 3 raster maps (red, green, and blue channels) with
r.in.gdal, move the maps to the correct size and location with
r.region, then display them with d.rgb.
This may produce resampling artifacts. Display modules such as d.rgb
will have the input maps resampled to the current region, and will
then resample them to the display resolution.
Setting the current region bounds and resolution to match the display
pixel grid will eliminate one resampling step. Using "r.region -c ..."
to match the raster to the current region will eliminate the other.
Alternatively, if you have the PNG driver generate PPM output (e.g.
GRASS_PNGFILE=map.ppm), you can use g.pnmcomp to composite multiple
PPM/PGM images (all images need to have the same dimensions, and each
PPM file needs a corresponding PGM file containing the alpha channel).
I would like to add a logo to a map that I am printing with the PNG
driver.
It is a .jpg, although I could switch it to another image type if that
was
helpful. Is there any way to do that?
Import it as 3 raster maps (red, green, and blue channels) with
r.in.gdal, move the maps to the correct size and location with
r.region, then display them with d.rgb.
Thank you for the instructions. I am getting an error message with
r.in.gdal, though:
WARNING: G_set_window(): Illegal latitude for North
At present, the file I have is not georeferenced at all - it is just a
normal jpeg. To experiment I tried changing it to a tiff and importing, but
same problem. Do I need to somehow define the region of the image before
importing?
Also, I was not sure how to import as separate r,g,b maps. Is that just a
matter of having band=1, band=2, band=3 in three iterations of r.in.gdal? I
tried to experiment with that a bit, but was still having the 'illegal north
latitude' problem so didn't get anywhere.
This proceeds, and generates the logo.tif group (you are right - it does
import with separate bands: logo.red, logo.green, logo.blue). However, it
gives the error message
Error : band 1 has no color table
When I do r.in.gdal,
r.in.gdal -o input=/usr/logo.tif output=logo
it does import the file successfully (as opposed to before giving that
"illegal north latitude" error), so that is a step forward. But (as error
above would suggest), all the bands are either <null> or 0's.
This proceeds, and generates the logo.tif group (you are right - it does
import with separate bands: logo.red, logo.green, logo.blue).
Correction:
Sorry, I just realized I wrote something misleading in the above.
gdal_translate does not generate the image group - it generates a single
file 'logo.tif' in the root directory. The individual rasters for the three
bands (logo.red, .green, .blue) are generated by r.in.gdal.