Search code examples
svgmergephotoshoptiffadobe-illustrator

Merge a svg file onto multiple tif files by scripting


I have a vector picture file (svg or Adobe Illustrator). This file is a "grid". I have over thousand tif pictures that I want to apply this grid onto.

Is there an easy automated way to do this? Thank you so much!


Solution

  • There are loads of ways you could do this. I'd probably export the grid as a .tif file of the same dimensions and then use ImageMagick to combine the images (it can read SVGs directly, but it's not so good at rendering them). Here's an example:


    graph.tif:
    graph without grid


    grid.tif:
    grid image


    command line syntax:

    composite -compose Multiply graph.tif grid.tif graph2.tif
    

    Result (grid2.tif):
    combined graph plus grid


    You can use command line scripting to apply the same grid to multiple images, e.g.:

    for (( i=1; i<=4; i++ )) do
        composite -compose Multiply graph-$i.tif grid.tif graph2-$i.tif
    done
    

    This will add grids to images called graph-1.tif, graph-2.tif. graph-3.tif etc. in the current directory, and save the results as graph2-1.tif, graph2-2.tif. graph2-3.tif etc.