0

I am using the GraphicsMagick module for node.js to manipulate my multipage Tiff document. I am trying to find a way to rotate a specific page and rotate it without splitting the file into individual tiff files, do the operation and then merge them. Currently the only way i know how to rotate pages using GM is:

gm("uploads/multipage_tiff_example_copy.tif").rotate('white',90).write('uploads/temp.tif',(err)=>{
            if(err)
                console.log(err);
            else
                console.log('Rotated');
        });

The code above rotates all my pages in the tiff file. Can someone please help me find a way to select a specific page and then rotate it without splitting the file.

Thank you!

Vmal
  • 27
  • 9

1 Answers1

0

I do not know about GraphicsMagick, since it is a much older version of ImageMagick and has not changed much. But in ImageMagick, you can do the following.

Create a test 4 page tiff from 4 copies of the ImageMagick internal image, logo:

convert logo: logo: logo: logo: logo.tif

Rotate the second page by cloning it, rotating it, then swapping the rotated cloned version with the original second page and deleting the original second page.

convert logo.tif \( -clone 1 -rotate 90 \) -swap 4,1 +delete logo2.tif

Note that images in the command line sequence (page number here) start with index 0. So the second page is index 1.

fmw42
  • 46,825
  • 10
  • 62
  • 80