TiffImage.Save

Hello

TiffImage.Save(target, True)
TiffImage.Save(target, SaveOptions)

One of the above overload can be used, not both like this:

TiffImage.Save(target, SaveOptions, True)

What about specifying Overwrite in SaveOptions? Or add a mixed overload like above sample?

Also, how to use SaveOptions for TiffImage.Save?
Thanks.

Hi, @australian.dev.nerds.
Some save methods are legacy ones. That’s why we have them all. :slight_smile:
But there is some difference between using SaveOptions and not using it.

When you call Image.Save() you save the image to the same location (that you specified when called Image.Load and in the same image format.

When you call Image.Save(Stream stream) you save the image to the specified stream in the same image format.

When you call Image.Save(filePath) you save the image to the specified location in the format defined by filePath extension.

When you use Image.Save(filePath/Stream, ImageOptionBase saveOptions) you can export the image in any supported formats by using necessary saveOptions, for example:

using (TiffImage image = (TiffImage)Image.Load("some-tif.tiff"))
{
	// save as png
   image.Save("output-image.png", new PngOptions());
 	// save as gif
   image.Save("output-image.gif", new GifOptions());
	// save as pdf
    image.Save("output-image.pdf", new PdfOptions());
   // save as svg
   image.Save("output-image.svg", new SvgOptions());
   // and so on
}

When you use Image.Save(filePath/Stream, ImageOptionBase saveOptions, Rectangle rectange) you can export a part of image defined by rectange (cropping) in any supported formats by using necessary saveOptions.

And finally:
When you use Image.Save(Sting filePath, any parameters, bool overWrite), the export will be performed correctly only if a file filePath does not exist.

1 Like

Thanks for your great info, this part was vital, pity that not mentioned in the docs :frowning: