Montage set const page width and height

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
architektura
Posts: 21
Joined: 2016-10-03T05:11:21-07:00
Authentication code: 1151

Montage set const page width and height

Post 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));
architektura
Posts: 21
Joined: 2016-10-03T05:11:21-07:00
Authentication code: 1151

Re: Montage set const page width and height

Post by architektura »

and what I can do to write multipage pdf in c# - this is impossible?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Montage set const page width and height

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
architektura
Posts: 21
Joined: 2016-10-03T05:11:21-07:00
Authentication code: 1151

Re: Montage set const page width and height

Post 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...
architektura
Posts: 21
Joined: 2016-10-03T05:11:21-07:00
Authentication code: 1151

Re: Montage set const page width and height

Post 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
                    }

               
            }
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage set const page width and height

Post by fmw42 »

Montage does not have page size controls. You could just resize the result to your desired results.
architektura
Posts: 21
Joined: 2016-10-03T05:11:21-07:00
Authentication code: 1151

Re: Montage set const page width and height

Post 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)
Post Reply