Page 1 of 1

Montage set const page width and height

Posted: 2017-07-11T03:08:31-07:00
by architektura
1]
in cmd line is simple - page 842x595 (horizontal a4)
but how I can make constans page widht and height into c#

if I write

Code: Select all

ms.Geometry.Width = 842;
ms.Geometry.Height = 595;
or

Code: Select all

montageResult.Page.Width = 842;
montageResult.Page.Height = 595;
page still have size which is different than a4 or horizontal a4

2]
this is near 1]

how to setup this to make tile 1x1,2x2,3x3, ect - I can setup variables but I cant insert into any other number into bracket {} than "0"- if I change zero to any greater number - I get error "Additional information: Index (zero based) must be greater than or equal to zero and less than the size of the argument list." - ms.TileGeometry = new MagickGeometry(string.Format("{3}x", 5)); for example

Code: Select all

ms.Geometry = new MagickGeometry(string.Format("{0}x{1}", tempWidth, tempHeight));
ms.TileGeometry = new MagickGeometry(string.Format("{0}x", 5));

Re: Montage set const page width and height

Posted: 2017-07-12T06:10:15-07:00
by architektura
and what I can do to write multipage pdf in c# - this is impossible?

Re: Montage set const page width and height

Posted: 2017-07-15T08:30:09-07:00
by dlemstra
Not sure why you would need -page for montage. Why do you need to set it?

You can set the tile geometry like this:

Code: Select all

ms.TileGeometry = new MagickGeometry(2, 2); // for 2x2
And if you want to write multiple pages you will need to use the MagickImageCollection class.

Re: Montage set const page width and height

Posted: 2017-07-16T22:48:09-07:00
by architektura
Hi I want to setup paper form - horizontal A4 - 842 x 595

if I use for example

Code: Select all

montageResult.Page.Width = 842;
 montageResult.Page.Height = 595;
page are not A4 horizontal - page width and height are depend on images...

Re: Montage set const page width and height

Posted: 2017-07-16T23:35:09-07:00
by architektura
Hi again - I used collection class but page's still are overwitten - if I choose for example 12 pictures with tile 2x2 I get 1 page which overwiritten 3 times...

Code: Select all

List<string> lFiles = new List<string>();
            foreach (String filename in openFileDialog1.FileNames)
                lFiles.Add(filename);

            using (MagickImageCollection images = new MagickImageCollection())
            {
               
                int sizer = 300;
                foreach (string tempFile in lFiles)
                {

                    MagickImage magickinput = new MagickImage(tempFile);

                    magickinput.Quality = 70;
                    if (magickinput.Height > magickinput.Width)
                    {
                        magickinput.Rotate(90);
                    }
                    magickinput.Resize(sizer, 0);
                    magickinput.CompressionMethod = CompressionMethod.JPEG;
                    images.Add(magickinput);
  		}
                    tempWidth = 842 ;
                    tempHeight = 595 ;

                    MontageSettings ms = new MontageSettings();
                    ms.BorderWidth = 10;
                    ms.Geometry = new MagickGeometry(2, 2, tempWidth, tempHeight);
                    ms.TileGeometry = new MagickGeometry(2, 2);
                    ms.Label = Path.Combine(Path.GetFileName(imageFileName));
               

                    using (MagickImage montageResult = images.Montage(ms))
                    {
                      
                       // montageResult.Page.Width = 842;
                       // montageResult.Page.Height = 595;
                                   
                        montageResult.Write(imageFileName); //image with path
                    }

               
            }

Re: Montage set const page width and height

Posted: 2017-07-17T00:57:42-07:00
by fmw42
Montage does not have page size controls. You could just resize the result to your desired results.

Re: Montage set const page width and height

Posted: 2017-07-17T01:11:49-07:00
by architektura
@page resize
from comand line I can set -page width_x_height :/
(resize working :))

@overwrite
how to prevent overwirting page and make multipage pdf? (as code above)