Convert to Image with advanced options
GroupDocs.Conversion provides ImageConvertOptions to give you control over conversion result when convert to image. Along with common convert options from base class ImageConvertOptions has the following additional options:
- setFormat - desired result document type. Available options are: Tiff, Tif, Jpg, Jpeg, Png, Gig, Bmp, Ico, Psd, Wmf, Emf, Dcm, Webp, Dng, Svg, Jp2, Odg, J2c, J2k, Jpx, Jpf, Jpm, Eps, Cgm, Cdr, Cmx, Dib, Jpc, Jls, DjVu
- setWidth - desired image width after conversion
- setHeight - desired image height after conversion
- setHorizontalResolution - desired image horizontal resolution after conversion
- setVerticalResolution - desired image vertical resolution after conversion
- setGrayscale - if true converted image will be grayscaled
- setRotateAngle - image rotation angle
- setFlipMode - image flip mode. Available options are: None, FlipX, FlipY, FlipXY
- setBrightness - adjusts image brightness
- setContrast - adjusts image contrast
- setGamma - adjust image gamma
- setJpegOptions - JPEG specific convert options
- setTiffOptions - TIFF specific convert options
- setPsdOptions - PSD specific convert options
- setWebpOptions - WebP specific convert options
- setUsePdf - in some cases, for better rendering and elements positioning the source document should be converted to PDF first. If this property is set to true, the input firstly is converted to PDF and after that to desired format.
Following code snippet shows how to convert to image with advanced options
String outputFileTemplate = "ConvertToImageWithAdvancedOptions-converted-page-%s.png";
try {
FileOutputStream getPageStream = new FileOutputStream(String.format(outputFileTemplate, 1));
Converter converter = new Converter("sample.pdf");
ImageConvertOptions options = new ImageConvertOptions();
options.setFormat(ImageFileType.Png);
options.setFlipMode(ImageFlipModes.FlipY);
options.setBrightness(50);
options.setContrast(50);
options.setGamma(0.5F);
options.setGrayscale(true);
options.setHorizontalResolution(300);
options.setVerticalResolution(100);
options.setPageNumber(1);
options.setPagesCount(1);
converter.convert(getPageStream, options);
} catch (IOException e) {
System.out.println(e.getMessage());
}
JpegOptions
JpegOptions is subset of ImageConvertOptions which allow enhanced control over conversions to JPEG format.
The following options are available:
- setQuality - desired image quality.
- setColorMode - JPEG color mode. Available options are: Rgb, YCbCr, Cmyk, Ycck, Grayscale
- setCompression - JPEG compression methods. Available options are: Baseline, Progressive, Lossless, JpegLs
TiffOptions
TiffOptions is subset of ImageConvertOptions which allow enhanced control over conversions to TIFF format.
The following options are available:
- setCompression - TIFF compression method. Available options are: None, Lzw, Ccitt3, Ccitt4, Rle
PsdOptions
PsdOptions is subset of ImageConvertOptions which allow enhanced control over conversions to PSD format.
The following options are available:
- setChannelBitsCount - bits count per channel
- setChannelsCount - color channels count
- setColorMode - PSD color mode. Available options are: Bitmap, Grayscale, Indexed, Rgb, Cmyk, Multichannel, Duotone, Lab
- setCompression - PSD compression method. Available options are: Raw, Rle, ZipWithoutPrediction, ZipWithPrediction
- setVersion - desired PSD version
WebpOptions
WebpOptions is subset of ImageConvertOptions which allow enhanced control over conversions to WebP format.
The following options are available:
- setLossless - the compression of the converted image will be lossless.
- setQuality - set the quality of converted image
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Conversion for .NET examples, plugins, and showcase
- GroupDocs.Conversion for Java examples, plugins, and showcase
- Document Conversion for .NET MVC UI Example
- Document Conversion for .NET App WebForms UI Modern Example
- Document Conversion for Java App Dropwizard UI Modern Example
- Document Conversion for Java Spring UI Example
Free Online Document Converter Apps
Along with full-featured Java library we provide free Apps and free services for document conversion.
In order to see a full potential of GroupDocs.Conversion, you are welcome to convert DOC to PDF, DOC to XLSX, PDF to DOC, PDF to XLSX, PPT to DOC and more with Free Online Document Converter App or get a full advantage of Free Online Document Converter Suite with advanced conversion settings and many more enterprise built-in features.
Please note that more premium features, advanced options and enhanced document management experience is available for signed-in users at conholdate.app for FREE.
If you don’t own an account yet, register it now for free! No credit card is required!