[magick-users] Tile cropping with overlap ?

Anthony Thyssen anthony at griffith.edu.au
Thu Mar 6 17:25:17 PST 2008


magickusers.domain.thewild at spamgourmet.org on  wrote...
| Hi list !
|
| I am trying to accomplish a quite simple task with imagemagick : cropping an
| image into tiles of a given dimension *with overlap* between the tiles.
| Cropping is easy : convert myimage.jpg -crop <sizex>x<sizey> myoutpout%d.jpg
| But I can't find a way to tell convert that I want the tiles to overlap by a
| certain amount (in pixels).

There is no such option in IM at this time!  Sorry.

The best solution is to write your own image tile spliting program.


One faster solution could be to make tricky use of the new
"-layers composite" to generate the tiles at the size wanted.

Something like...
   read in image
   make a clone of the original image, and tile crop it
         add a border to each tile the size of the overlap
         relative page adjust the position by a negative amount
   add a "null:" image sequence seperation marker
   move the original image to the end of sequence
   now use -compose Src -layers composite  to copy the original image
   into the areas marked by the adjusted tile images.
   OPTIONALLY remove canvas size and offsets using +repage

Hey its tricy but works!!!!

  convert logo: -matte \
       \( +clone -crop 100x100 -border 20x20 -repage -20-20\! \) \
      null: \( -clone 0 \) -delete 0 \
      -compose Src -layers composite +repage  tiles_%d.gif

The trickyness is that I use the virtual image positions that tile crop
leaves behind, then adjust the tiles size and position, so as to use
them as 'cookie cutters' for the original image.

The question is, where in IM examples should I place this!!

Most likely in advanced, as it relays on lots of fancy interaction
of image operations.


| convert myimage.jpg -crop <sizex>x<sizey>+<offsetx>+<offsety> myoutpout%d.jpg
| does not work, it just produces the first tile with an offset (i.e., it is the
| same with or without the "%d").
|
| Is this possible with convert ?
|
In answer YES, but not directly!!!


  Anthony Thyssen ( System Programmer )    <A.Thyssen at griffith.edu.au>
 -----------------------------------------------------------------------------
  Applications Programming is a race between software engineers striving
  to build bigger and better idiot-proof programs, and the Universe trying
  to produce bigger and better idiots.  So far, the Universe is winning.
                                     -- Rick Cook, "The Wizardry Compiled"
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/


More information about the Magick-users mailing list