Saving Resized Images of Docs in Script -

Saving Resized Images of Documents in Script

IEditablePictureObject pic = Document.Pages[0].Picture.CreateEditableCopy();

Double ratio;
Int32 newheight = 500;
Int32 newwidth = 300;
const Int32 maxheight = 500;
const Int32 maxwidth = 300;
Double width = pic.Width; // get width and height of original image
Double height = pic.Height;

// determine which side is the longest to use in calculating length of the shorter side,
// since the longest will be the max size for whichever side is longest.
if (height > width)
{
ratio = maxheight / height;
newheight = maxheight;
newwidth = (int)Math.Floor(width * ratio);
}
else
{
ratio = maxwidth / width;
newwidth = maxwidth;
newheight = (int)Math.Floor(height * ratio);
}

pic.FreeScale(newwidth,newheight, 300);
IExportImageSavingOptions imageOptions = FCTools.NewImageSavingOptions();
imageOptions.Format = “jpg";
imageOptions.ColorType = “GrayScale";
//imageOptions.Resolution = 300;
imageOptions.ShouldOverwrite = true;
imageOptions.AddProperFileExt = true;
imageOptions.Quality = 99;

pic.SaveAs( savePath, imageOptions );