Packages

 

com.aspose.imaging.fileformats.jpeg

Class JpegImage

  • All Implemented Interfaces:
    IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, com.aspose.imaging_internal.IPixelsSaver, com.aspose.ms.System.IDisposable, Closeable, AutoCloseable


    public final class JpegImage
    extends RasterCachedImage

    A jpeg image.

    Code example:

    The example shows how to load a JpegImage from a file.


    String dir = "c:\\temp\\";
    
    // Load a JPEG image from a file.
    com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = new com.aspose.imaging.fileformats.jpeg.JpegImage(dir + "sample.jpg");
    try {
        // Do some image processing.
        // Save to another JPEG file.
        jpegImage.save(dir + "sample.output.jpg");
    } finally {
        jpegImage.dispose();
    }
    

    • Constructor Detail

      • JpegImage

        public JpegImage(String path)

        Initializes a new instance of the JpegImage class.

        Parameters:
        path - The path to load image from and initialize pixel and palette data with.
        Code example:

        The example shows how to load a JpegImage from a file.


        String dir = "c:\\temp\\";
        
        // Load a JPEG image from a file.
        com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = new com.aspose.imaging.fileformats.jpeg.JpegImage(dir + "sample.jpg");
        try {
            // Do some image processing.
            // Save to another JPEG file.
            jpegImage.save(dir + "sample.output.jpg");
        } finally {
            jpegImage.dispose();
        }
        

      • JpegImage

        public JpegImage(InputStream stream)

        Initializes a new instance of the JpegImage class.

        Parameters:
        stream - The stream to load image from and initialize pixel and palette data with.
        Code example:

        The example shows how to load a JpegImage from a file stream.


        String dir = "c:\\temp\\";
        
        // Load a JPEG image from a file stream.
        java.io.InputStream stream = new java.io.FileInputStream(dir + "sample.jpg");
        try {
            com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = new com.aspose.imaging.fileformats.jpeg.JpegImage(stream);
            try {
                // Do some image processing.
                // Save to another JPEG file.
                jpegImage.save(dir + "sample.output.jpg");
            } finally {
                jpegImage.dispose();
            }
        } finally {
            stream.close();
        }
        

      • JpegImage

        public JpegImage(RasterImage rasterImage)

        Initializes a new instance of the JpegImage class.

        Parameters:
        rasterImage - The image to initialize pixel and palette data with.
        Code example:

        The example shows how to load a JpegImage from another RasterImage.


        String dir = "c:\\temp\\";
        
        // Load a JPEG image from another raster image.
        // First, create a temporal PNG image that will be a foundation for building a JPEG image.
        // You can also load PNG image from a file or use an image of any other raster format.
        com.aspose.imaging.imageoptions.PngOptions createOptions = new com.aspose.imaging.imageoptions.PngOptions();
        createOptions.setSource(new com.aspose.imaging.sources.StreamSource(new java.io.ByteArrayInputStream(new byte[0]), false));
        com.aspose.imaging.RasterImage rasterImage = (com.aspose.imaging.RasterImage) com.aspose.imaging.Image.create(createOptions, 100, 100);
        try {
            // Fill the entire PNG image in red.
            com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(rasterImage);
            com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed());
            graphics.fillRectangle(brush, rasterImage.getBounds());
        
            // Create a JPEG image based on the PNG image.
            com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = new com.aspose.imaging.fileformats.jpeg.JpegImage(rasterImage);
            try {
                // Save to a JPEG file
                jpegImage.save(dir + "output.jpg");
            } finally {
                jpegImage.dispose();
            }
        } finally {
            rasterImage.dispose();
        }
        

      • JpegImage

        public JpegImage(int width,
                         int height)

        Initializes a new instance of the JpegImage class.

        Parameters:
        width - The image width.
        height - The image height.
        Code example:

        The following example shows how to create JPEG image of the specified size.


        String dir = "c:\\temp\\";
        
        // Create a JPEG image of 100x100 px.
        com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = new com.aspose.imaging.fileformats.jpeg.JpegImage(100, 100);
        try {
            // Do some image processing.
            // Save to a file.
            jpegImage.save(dir + "output.jpg");
        } finally {
            jpegImage.dispose();
        }
        

      • JpegImage

        public JpegImage(JpegOptions jpegOptions,
                         int width,
                         int height)

        Initializes a new instance of the JpegImage class.

        Parameters:
        jpegOptions - The jpeg options.
        width - Image width.
        height - Image height.
        Code example:

        The following example shows how to create JPEG image of the specified size with the specified parameters.


        String dir = "c:\\temp\\";
        
        // Create a JPEG image of 100x100 px.
        // Use additional options to specify the desired image parameters.
        com.aspose.imaging.imageoptions.JpegOptions createOptions = new com.aspose.imaging.imageoptions.JpegOptions();
        
        // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly.
        createOptions.setBitsPerChannel((byte) 8);
        
        // Set the progressive type of compression.
        createOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.Progressive);
        
        // Set the image quality. It is a value between 1 and 100.
        createOptions.setQuality(100);
        
        // Set the horizontal/vertical resolution to 96 dots per inch.
        createOptions.setResolutionSettings(new com.aspose.imaging.ResolutionSetting(96.0, 96.0));
        createOptions.setResolutionUnit(com.aspose.imaging.ResolutionUnit.Inch);
        
        // This is a standard option for JPEG images.
        // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed.
        createOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.YCbCr);
        
        com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = new com.aspose.imaging.fileformats.jpeg.JpegImage(createOptions, 100, 100);
        try {
            com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(jpegImage);
        
            com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush(
                    new com.aspose.imaging.Point(0, 0),
                    new com.aspose.imaging.Point(jpegImage.getWidth(), jpegImage.getHeight()),
                    com.aspose.imaging.Color.getYellow(),
                    com.aspose.imaging.Color.getBlue());
        
            // Fill the image with a grayscale gradient
            graphics.fillRectangle(gradientBrush, jpegImage.getBounds());
        
            // Save to a file.
            jpegImage.save(dir + "output.explicitoptions.jpg");
        } finally {
            jpegImage.dispose();
        }
        

    • Method Detail

      • getFileFormat

        public long getFileFormat()

        Gets a value of file format

        Overrides:
        getFileFormat in class Image
      • getJpegOptions

        public JpegOptions getJpegOptions()

        Gets the JPEG options used to create or load this JpegImage instance.

        Returns:
        The JPEG options.
        Code example:

        The following example shows how to extract the header information from a JPEG image.


        String dir = "c:\\temp\\";
        
        com.aspose.imaging.fileformats.jpeg.JpegImage image = (com.aspose.imaging.fileformats.jpeg.JpegImage) com.aspose.imaging.Image.load(dir + "original.jpg");
        try {
            com.aspose.imaging.imageoptions.JpegOptions jpegOptions = image.getJpegOptions();
        
            System.out.println("The number of bits per channel: " + jpegOptions.getBitsPerChannel());
            System.out.println("The max allowed size for all internal buffers: " + jpegOptions.getBufferSizeHint());
            System.out.println("The color type: " + jpegOptions.getColorType());
            System.out.println("The compression type: " + jpegOptions.getCompressionType());
            System.out.println("The image quality: " + jpegOptions.getQuality());
        
            if (jpegOptions.getResolutionSettings() != null) {
                System.out.println("The horizontal resolution: " + jpegOptions.getResolutionSettings().getHorizontalResolution());
                System.out.println("The vertical resolution: " + jpegOptions.getResolutionSettings().getVerticalResolution());
            }
        
            for (int i = 0; i < jpegOptions.getHorizontalSampling().length; i++) {
                System.out.printf("The sampling for component %s: %sx%s\r\n", i, jpegOptions.getHorizontalSampling()[i], jpegOptions.getVerticalSampling()[i]);
            }
        } finally {
            image.dispose();
        }
        
        //The output looks like this:
        //The number of bits per channel: 8
        //The max allowed size for all internal buffers: 0
        //The color type: YCbCr
        //The compression type: Baseline
        //The image quality: 75
        //The sampling for component 0: 1x1
        //The sampling for component 1: 1x1
        //The sampling for component 2: 1x1
        

      • getBitsPerPixel

        public int getBitsPerPixel()

        Gets the image bits per pixel count.

        Specified by:
        getBitsPerPixel in class Image
        Returns:
        The image bits per pixel count.
      • getComment

        public String getComment()

        Gets the jpeg file comment.

      • setComment

        public void setComment(String value)

        Sets the jpeg file comment.

      • getExifData

        public JpegExifData getExifData()

        Get or set exif data container

        Code example:

        The following example shows how to extract EXIF tags from a JPEG image.


        String dir = "c:\\temp\\";
        
        com.aspose.imaging.fileformats.jpeg.JpegImage image = (com.aspose.imaging.fileformats.jpeg.JpegImage) com.aspose.imaging.Image.load(dir + "original.jpg");
        try {
            com.aspose.imaging.exif.ExifData exifData = image.getExifData();
        
            System.out.println("The general EXIF data");
            System.out.println("------------------------------------------");
            if (exifData != null) {
                System.out.println("The EXIF version: " + exifData.getExifVersion());
                System.out.println("The camera serial number: " + exifData.getBodySerialNumber());
                System.out.println("The color space: " + exifData.getColorSpace());
                System.out.println("The brightness: " + exifData.getBrightnessValue());
                System.out.println("The contrast: " + exifData.getContrast());
                System.out.println("The gamma: " + exifData.getGamma());
                System.out.println("The sharpness: " + exifData.getSharpness());
                System.out.println("The aperture: " + exifData.getApertureValue());
                System.out.println("The exposure mode: " + exifData.getExposureMode());
                System.out.println("The exposure bias: " + exifData.getExposureBiasValue());
                System.out.println("The exposure time: " + exifData.getExposureTime());
                System.out.println("The focal length: " + exifData.getFocalLength());
                System.out.println("The focal plane resolution unit: " + exifData.getFocalPlaneResolutionUnit());
                System.out.println("The lens model: " + exifData.getLensModel());
                System.out.println("The shutter speed: " + exifData.getShutterSpeedValue());
            }
        
            System.out.println("The JPEG EXIF data");
            System.out.println("------------------------------------------");
            if (exifData instanceof com.aspose.imaging.exif.JpegExifData) {
                com.aspose.imaging.exif.JpegExifData jpegExifData = (com.aspose.imaging.exif.JpegExifData) exifData;
        
                System.out.println("The camera manufacturer: " + jpegExifData.getMake());
                System.out.println("The camera model: " + jpegExifData.getModel());
                System.out.println("The photometric interpretation: " + jpegExifData.getPhotometricInterpretation());
                System.out.println("The artist: " + jpegExifData.getArtist());
                System.out.println("The copyright: " + jpegExifData.getCopyright());
                System.out.println("The image description: " + jpegExifData.getImageDescription());
                System.out.println("The orientation: " + jpegExifData.getOrientation());
                System.out.println("The software: " + jpegExifData.getSoftware());
            }
        } finally {
            image.dispose();
        }
        
        //The output looks like this:
        //The general EXIF data
        //------------------------------------------
        //The EXIF version: [B@163e4e87
        //The camera serial number: 7100536
        //The color space: SRgb
        //The brightness:
        //The contrast: Normal
        //The gamma:
        //The sharpness: 0
        //The aperture: 4.64(4643856 / 1000000)
        //The exposure mode: Manual
        //The exposure bias: 0.67(4 / 6)
        //The exposure time: 0.01(1 / 160)
        //The focal length: 145.00(1450 / 10)
        //The focal plane resolution unit: Cm
        //The lens model: 70.0 - 200.0 mm f/ 4.0
        //The shutter speed: 7.32(7321928 / 1000000)
        //The JPEG EXIF data
        //------------------------------------------
        //The camera manufacturer: NIKON CORPORATION
        //The camera model: NIKON D5
        //The photometric interpretation: 0
        //The artist:
        //The copyright:
        //The image description:
        //The orientation: TopLeft
        //The software: Adobe Photoshop Camera Raw 9.9(Macintosh)
        

      • setExifData

        public void setExifData(JpegExifData value)

        Get or set exif data container

      • getHorizontalResolution

        public double getHorizontalResolution()

        Gets the horizontal resolution, in pixels per inch, of this RasterImage.

        Overrides:
        getHorizontalResolution in class RasterImage
        Returns:
        The horizontal resolution.

        Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.

        Code example:

        The following example shows how to set horizontal/vertical resolution of a JPEG image.


        String dir = "c:\\temp\\";
        
        com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.jpg");
        try {
            com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = (com.aspose.imaging.fileformats.jpeg.JpegImage) image;
        
            // Get horizontal and vertical resolution of the BmpImage
            double horizontalResolution = jpegImage.getHorizontalResolution();
            double verticalResolution = jpegImage.getVerticalResolution();
            System.out.println("The horizontal resolution, in pixels per inch: " + horizontalResolution);
            System.out.println("The vertical resolution, in pixels per inch: " + verticalResolution);
        
            if (horizontalResolution != 96.0 || verticalResolution != 96.0) {
                // Use the SetResolution method for updating both resolution values in a single call.
                System.out.println("Set resolution values to 96 dpi");
                jpegImage.setResolution(96.0, 96.0);
        
                System.out.println("The horizontal resolution, in pixels per inch: " + jpegImage.getHorizontalResolution());
                System.out.println("The vertical resolution, in pixels per inch: " + jpegImage.getVerticalResolution());
            }
        } finally {
            image.dispose();
        }
        
        // The output may look like this:
        // The horizontal resolution, in pixels per inch: 300.0
        // The vertical resolution, in pixels per inch: 300.0
        // Set resolution values to 96 dpi
        // The horizontal resolution, in pixels per inch: 96.0
        // The vertical resolution, in pixels per inch: 96.0
        

      • setHorizontalResolution

        public void setHorizontalResolution(double value)

        Sets the horizontal resolution, in pixels per inch, of this RasterImage.

        Overrides:
        setHorizontalResolution in class RasterImage
        Parameters:
        value - The horizontal resolution.

        Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.

      • getJfif

        public JFIFData getJfif()

        Gets the jfif.

      • setJfif

        public void setJfif(JFIFData value)

        Sets the jfif.

      • getVerticalResolution

        public double getVerticalResolution()

        Gets the vertical resolution, in pixels per inch, of this RasterImage.

        Overrides:
        getVerticalResolution in class RasterImage
        Returns:
        The vertical resolution.

        Note by default this value is always 72 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.

        Code example:

        The following example shows how to set horizontal/vertical resolution of a JPEG image.


        String dir = "c:\\temp\\";
        
        com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.jpg");
        try {
            com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = (com.aspose.imaging.fileformats.jpeg.JpegImage) image;
        
            // Get horizontal and vertical resolution of the BmpImage
            double horizontalResolution = jpegImage.getHorizontalResolution();
            double verticalResolution = jpegImage.getVerticalResolution();
            System.out.println("The horizontal resolution, in pixels per inch: " + horizontalResolution);
            System.out.println("The vertical resolution, in pixels per inch: " + verticalResolution);
        
            if (horizontalResolution != 96.0 || verticalResolution != 96.0) {
                // Use the SetResolution method for updating both resolution values in a single call.
                System.out.println("Set resolution values to 96 dpi");
                jpegImage.setResolution(96.0, 96.0);
        
                System.out.println("The horizontal resolution, in pixels per inch: " + jpegImage.getHorizontalResolution());
                System.out.println("The vertical resolution, in pixels per inch: " + jpegImage.getVerticalResolution());
            }
        } finally {
            image.dispose();
        }
        
        // The output may look like this:
        // The horizontal resolution, in pixels per inch: 300.0
        // The vertical resolution, in pixels per inch: 300.0
        // Set resolution values to 96 dpi
        // The horizontal resolution, in pixels per inch: 96.0
        // The vertical resolution, in pixels per inch: 96.0
        

      • setVerticalResolution

        public void setVerticalResolution(double value)

        Sets the vertical resolution, in pixels per inch, of this RasterImage.

        Overrides:
        setVerticalResolution in class RasterImage
        Parameters:
        value - The vertical resolution.

        Note by default this value is always 72 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.

      • getRgbColorProfile

        public StreamSource getRgbColorProfile()

        The RGB color profile for CMYK and YCCK jpeg images. Must be in pair with CMYKColorProfile for correct color conversion.

      • setRgbColorProfile

        public void setRgbColorProfile(StreamSource value)

        The RGB color profile for CMYK and YCCK jpeg images. Must be in pair with CMYKColorProfile for correct color conversion.

        Code example:

        The following example loads PNG and saves it to CMYK JPEG using custom ICC profile. Then loads CMYK JPEG and saves it back to PNG. The color conversion from RGB to CMYK and from CMYK to RGB is performed using custom ICC profiles.


        String dir = "c:\\temp\\";
        
        // Load PNG and save it to CMYK JPEG
        com.aspose.imaging.fileformats.png.PngImage image = (com.aspose.imaging.fileformats.png.PngImage) com.aspose.imaging.Image.load(dir + "sample.png");
        try {
            java.io.InputStream rgbProfileStream = new java.io.FileInputStream(dir + "eciRGB_v2.icc");
            java.io.InputStream cmykProfileStream = new java.io.FileInputStream(dir + "ISOcoated_v2_FullGamut4.icc");
            try {
                com.aspose.imaging.imageoptions.JpegOptions saveOptions = new com.aspose.imaging.imageoptions.JpegOptions();
                saveOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.Cmyk);
        
                // Use custom ICC profiles
                saveOptions.setRgbColorProfile(new com.aspose.imaging.sources.StreamSource(rgbProfileStream));
                saveOptions.setCmykColorProfile(new com.aspose.imaging.sources.StreamSource(cmykProfileStream));
        
                image.save(dir + "output.cmyk.jpg", saveOptions);
            } finally {
                rgbProfileStream.close();
                cmykProfileStream.close();
            }
        } finally {
            image.dispose();
        }
        
        // Load CMYK JPEG and save it to PNG
        com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = (com.aspose.imaging.fileformats.jpeg.JpegImage) com.aspose.imaging.Image.load(dir + "output.cmyk.jpg");
        try {
            java.io.InputStream rgbProfileStream = new java.io.FileInputStream(dir + "eciRGB_v2.icc");
            java.io.InputStream cmykProfileStream = new java.io.FileInputStream(dir + "ISOcoated_v2_FullGamut4.icc");
            try {
                // Use custom ICC profiles
                jpegImage.setRgbColorProfile(new com.aspose.imaging.sources.StreamSource(rgbProfileStream));
                jpegImage.setCmykColorProfile(new com.aspose.imaging.sources.StreamSource(cmykProfileStream));
        
                com.aspose.imaging.imageoptions.PngOptions saveOptions = new com.aspose.imaging.imageoptions.PngOptions();
                jpegImage.save(dir + "output.rgb.png", saveOptions);
            } finally {
                rgbProfileStream.close();
                cmykProfileStream.close();
            }
        } finally {
            jpegImage.dispose();
        }
        

      • getCmykColorProfile

        public StreamSource getCmykColorProfile()

        The CMYK color profile for CMYK and YCCK jpeg images. Must be in pair with RGBColorProfile for correct color conversion.

      • setCmykColorProfile

        public void setCmykColorProfile(StreamSource value)

        The CMYK color profile for CMYK and YCCK jpeg images. Must be in pair with RGBColorProfile for correct color conversion.

        Code example:

        The following example loads PNG and saves it to CMYK JPEG using custom ICC profile. Then loads CMYK JPEG and saves it back to PNG. The color conversion from RGB to CMYK and from CMYK to RGB is performed using custom ICC profiles.


        String dir = "c:\\temp\\";
        
        // Load PNG and save it to CMYK JPEG
        com.aspose.imaging.fileformats.png.PngImage image = (com.aspose.imaging.fileformats.png.PngImage) com.aspose.imaging.Image.load(dir + "sample.png");
        try {
            java.io.InputStream rgbProfileStream = new java.io.FileInputStream(dir + "eciRGB_v2.icc");
            java.io.InputStream cmykProfileStream = new java.io.FileInputStream(dir + "ISOcoated_v2_FullGamut4.icc");
            try {
                com.aspose.imaging.imageoptions.JpegOptions saveOptions = new com.aspose.imaging.imageoptions.JpegOptions();
                saveOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.Cmyk);
        
                // Use custom ICC profiles
                saveOptions.setRgbColorProfile(new com.aspose.imaging.sources.StreamSource(rgbProfileStream));
                saveOptions.setCmykColorProfile(new com.aspose.imaging.sources.StreamSource(cmykProfileStream));
        
                image.save(dir + "output.cmyk.jpg", saveOptions);
            } finally {
                rgbProfileStream.close();
                cmykProfileStream.close();
            }
        } finally {
            image.dispose();
        }
        
        // Load CMYK JPEG and save it to PNG
        com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = (com.aspose.imaging.fileformats.jpeg.JpegImage) com.aspose.imaging.Image.load(dir + "output.cmyk.jpg");
        try {
            java.io.InputStream rgbProfileStream = new java.io.FileInputStream(dir + "eciRGB_v2.icc");
            java.io.InputStream cmykProfileStream = new java.io.FileInputStream(dir + "ISOcoated_v2_FullGamut4.icc");
            try {
                // Use custom ICC profiles
                jpegImage.setRgbColorProfile(new com.aspose.imaging.sources.StreamSource(rgbProfileStream));
                jpegImage.setCmykColorProfile(new com.aspose.imaging.sources.StreamSource(cmykProfileStream));
        
                com.aspose.imaging.imageoptions.PngOptions saveOptions = new com.aspose.imaging.imageoptions.PngOptions();
                jpegImage.save(dir + "output.rgb.png", saveOptions);
            } finally {
                rgbProfileStream.close();
                cmykProfileStream.close();
            }
        } finally {
            jpegImage.dispose();
        }
        

      • getDestinationRgbColorProfile

        public StreamSource getDestinationRgbColorProfile()

        The RGB color profile for CMYK and YCCK jpeg images, used for image saving process. Must be in pair with CMYKColorProfile for correct color conversion.

      • setDestinationRgbColorProfile

        public void setDestinationRgbColorProfile(StreamSource value)

        The RGB color profile for CMYK and YCCK jpeg images, used for image saving process. Must be in pair with CMYKColorProfile for correct color conversion.

      • getDestinationCmykColorProfile

        public StreamSource getDestinationCmykColorProfile()

        The CMYK color profile for CMYK and YCCK jpeg images, used for image saving process. Must be in pair with RGBColorProfile for correct color conversion.

      • setDestinationCmykColorProfile

        public void setDestinationCmykColorProfile(StreamSource value)

        The CMYK color profile for CMYK and YCCK jpeg images, used for image saving process. Must be in pair with RGBColorProfile for correct color conversion.

      • getIgnoreEmbeddedColorProfile

        public boolean getIgnoreEmbeddedColorProfile()

        Gets a value indicating whether embedded color profile is ignored. If embedded color profile is ignored, dafault color profile is used.

      • setIgnoreEmbeddedColorProfile

        public void setIgnoreEmbeddedColorProfile(boolean value)

        Sets a value indicating whether embedded color profile is ignored. If embedded color profile is ignored, dafault color profile is used.

      • setResolution

        public void setResolution(double dpiX,
                                  double dpiY)

        Sets the resolution for this RasterImage.

        Overrides:
        setResolution in class RasterImage
        Parameters:
        dpiX - The horizontal resolution, in dots per inch, of the RasterImage.
        dpiY - The vertical resolution, in dots per inch, of the RasterImage.
        Code example:

        The following example shows how to set horizontal/vertical resolution of a JPEG image.


        String dir = "c:\\temp\\";
        
        com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.jpg");
        try {
            com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = (com.aspose.imaging.fileformats.jpeg.JpegImage) image;
        
            // Get horizontal and vertical resolution of the BmpImage
            double horizontalResolution = jpegImage.getHorizontalResolution();
            double verticalResolution = jpegImage.getVerticalResolution();
            System.out.println("The horizontal resolution, in pixels per inch: " + horizontalResolution);
            System.out.println("The vertical resolution, in pixels per inch: " + verticalResolution);
        
            if (horizontalResolution != 96.0 || verticalResolution != 96.0) {
                // Use the SetResolution method for updating both resolution values in a single call.
                System.out.println("Set resolution values to 96 dpi");
                jpegImage.setResolution(96.0, 96.0);
        
                System.out.println("The horizontal resolution, in pixels per inch: " + jpegImage.getHorizontalResolution());
                System.out.println("The vertical resolution, in pixels per inch: " + jpegImage.getVerticalResolution());
            }
        } finally {
            image.dispose();
        }
        
        // The output may look like this:
        // The horizontal resolution, in pixels per inch: 300.0
        // The vertical resolution, in pixels per inch: 300.0
        // Set resolution values to 96 dpi
        // The horizontal resolution, in pixels per inch: 96.0
        // The vertical resolution, in pixels per inch: 96.0
        

      • autoRotate

        public void autoRotate()

        Perform automatic rotate of image depending on orientation data provided by Exif.