Search in sources :

Example 1 with FileImageOutputStreamExtImpl

use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.

the class JP2KWriteTest method write_Cprecincts.

// ////////////////////////////////////////////////////////////////////////
// 
// Testing "Cprecincts" Create Option.
// 
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_Cprecincts() throws IOException, FileNotFoundException {
    if (!isJp2KakDriverAvailable)
        return;
    LOGGER.info("Testing JP2 Write operation with Cprecincts option setting");
    // //
    // Preparing input/output files
    // //
    final File inputFile = TestData.file(this, testFileName);
    Assert.assertTrue(inputFile.exists());
    // Output files resulting from 2 different values of the same create
    // option. In this test, the create option is Cprecincts.
    final File outputFile1 = TestData.temp(this, "CprecintsA-.jp2", deleteTempFilesOnExit);
    final File outputFile2 = TestData.temp(this, "CprecintsB-.jp2", deleteTempFilesOnExit);
    // //
    // Preparing to read
    // //
    final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", inputFile);
    if (ENABLE_SUBSAMPLING) {
        ImageReadParam readParam = new ImageReadParam();
        readParam.setSourceSubsampling(4, 4, 0, 0);
        pbjImageRead.setParameter("readParam", readParam);
    }
    pbjImageRead.setParameter("Reader", new JP2GDALKakaduImageReaderSpi().createReaderInstance());
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (1ST version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile1));
    ImageWriter writer = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite.setParameter("Writer", writer);
    // Specifying image source to write
    pbjImageWrite.addSource(image);
    ImageWriteParam param = writer.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param).setCprecincts("{256,256},{256,256},{128,128}");
    pbjImageWrite.setParameter("writeParam", param);
    // Writing
    final RenderedOp op = JAI.create("ImageWrite", pbjImageWrite);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (2ND version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite2 = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite2.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile2));
    ImageWriter writer2 = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite2.setParameter("Writer", writer2);
    // Specifying image source to write
    pbjImageWrite2.addSource(image);
    ImageWriteParam param2 = writer2.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param2).setCprecincts("{512,512},{256,512},{128,512},{64,512},{32,512},{16,512},{8,512},{4,512},{2,512}");
    pbjImageWrite2.setParameter("writeParam", param2);
    // Writing
    final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
Also used : ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) ImageWriter(javax.imageio.ImageWriter) FileImageOutputStreamExtImpl(it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl) ImageWriteParam(javax.imageio.ImageWriteParam) File(java.io.File) Test(org.junit.Test)

Example 2 with FileImageOutputStreamExtImpl

use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.

the class JP2KWriteTest method write_GeoJp2.

// ////////////////////////////////////////////////////////////////////////
// 
// Testing "GeoJp2" Create Option.
// 
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_GeoJp2() throws IOException, FileNotFoundException {
    if (!isJp2KakDriverAvailable)
        return;
    LOGGER.info("Testing JP2 Write operation with GeoJp2 option setting");
    // //
    // Preparing input/output files
    // //
    final File inputFile = TestData.file(this, "bogota.jp2");
    Assert.assertTrue(inputFile.exists());
    // Output files resulting from 2 different values of the same create
    // option. In this test, the create option is GeoJp2.
    final File outputFile1 = TestData.temp(this, "GeoJp2-.jp2", deleteTempFilesOnExit);
    final File outputFile2 = TestData.temp(this, "NO-GeoJp2-.jp2", deleteTempFilesOnExit);
    // //
    // Preparing to read
    // //
    final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", inputFile);
    if (ENABLE_SUBSAMPLING) {
        ImageReadParam readParam = new ImageReadParam();
        readParam.setSourceSubsampling(4, 4, 0, 0);
        pbjImageRead.setParameter("readParam", readParam);
    }
    pbjImageRead.setParameter("Reader", new JP2GDALKakaduImageReaderSpi().createReaderInstance());
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (1ST version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile1));
    ImageWriter writer = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite.setParameter("Writer", writer);
    // Specifying image source to write
    pbjImageWrite.addSource(image);
    ImageWriteParam param = writer.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param).setGeoJp2("YES");
    pbjImageWrite.setParameter("writeParam", param);
    // Writing
    final RenderedOp op = JAI.create("ImageWrite", pbjImageWrite);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (2ND version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite2 = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite2.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile2));
    ImageWriter writer2 = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite2.setParameter("Writer", writer2);
    // Specifying image source to write
    pbjImageWrite2.addSource(image);
    ImageWriteParam param2 = writer2.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param2).setGeoJp2("NO");
    pbjImageWrite2.setParameter("writeParam", param2);
    // Writing
    final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
Also used : ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) ImageWriter(javax.imageio.ImageWriter) FileImageOutputStreamExtImpl(it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl) ImageWriteParam(javax.imageio.ImageWriteParam) File(java.io.File) Test(org.junit.Test)

Example 3 with FileImageOutputStreamExtImpl

use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.

the class JP2KWriteTest method write_Quality.

// ////////////////////////////////////////////////////////////////////////
// 
// Testing "Quality" Create Option.
// 
// ////////////////////////////////////////////////////////////////////////
// TODO: Investigate the strange displaying of a 100% quality factor write
// of an input UINT16 jpeg2000 image.
@Test
public void write_Quality() throws IOException, FileNotFoundException {
    if (!isJp2KakDriverAvailable)
        return;
    LOGGER.info("Testing JP2 Write operation with Quality option setting");
    // //
    // Preparing input/output files
    // //
    final File inputFile = TestData.file(this, testFileName);
    Assert.assertTrue(inputFile.exists());
    // Output files resulting from 2 different values of the same create
    // option. In this test, the create option is Qstep.
    final float firstQualityParam = 99.2f;
    final float secondQualityParam = 1f;
    final String fileName1 = new StringBuffer("Quality-").append(Float.toString(firstQualityParam)).append("f-.jp2").toString();
    final String fileName2 = new StringBuffer("Quality-").append(Float.toString(secondQualityParam)).append("f-.jp2").toString();
    final File outputFile1 = TestData.temp(this, fileName1, deleteTempFilesOnExit);
    final File outputFile2 = TestData.temp(this, fileName2, deleteTempFilesOnExit);
    // //
    // Preparing to read
    // //
    final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", inputFile);
    if (ENABLE_SUBSAMPLING) {
        ImageReadParam readParam = new ImageReadParam();
        readParam.setSourceSubsampling(4, 4, 0, 0);
        pbjImageRead.setParameter("readParam", readParam);
    }
    pbjImageRead.setParameter("Reader", new JP2GDALKakaduImageReaderSpi().createReaderInstance());
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (1ST version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile1));
    ImageWriter writer = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite.setParameter("Writer", writer);
    // Specifying image source to write
    pbjImageWrite.addSource(image);
    ImageWriteParam param = writer.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param).setQuality(firstQualityParam);
    pbjImageWrite.setParameter("writeParam", param);
    // Writing
    final RenderedOp op = JAI.create("ImageWrite", pbjImageWrite);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (2ND version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite2 = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite2.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile2));
    ImageWriter writer2 = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite2.setParameter("Writer", writer2);
    // Specifying image source to write
    pbjImageWrite2.addSource(image);
    ImageWriteParam param2 = writer2.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param2).setQuality(secondQualityParam);
    pbjImageWrite2.setParameter("writeParam", param2);
    // Writing
    final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
Also used : ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) ImageWriter(javax.imageio.ImageWriter) FileImageOutputStreamExtImpl(it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl) ImageWriteParam(javax.imageio.ImageWriteParam) ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) File(java.io.File) Test(org.junit.Test)

Example 4 with FileImageOutputStreamExtImpl

use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.

the class JP2KWriteTest method write_SProfile.

// ////////////////////////////////////////////////////////////////////////
// 
// Testing "SProfile" Create Option.
// 
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_SProfile() throws IOException, FileNotFoundException {
    if (!isJp2KakDriverAvailable)
        return;
    LOGGER.info("Testing JP2 Write operation with SProfile option setting");
    // //
    // Preparing input/output files
    // //
    final File inputFile = TestData.file(this, testFileName);
    Assert.assertTrue(inputFile.exists());
    // Output files resulting from 2 different values of the same create
    // option. In this test, the create option is SProfile.
    final File outputFile1 = TestData.temp(this, "SProfile1-.jp2", deleteTempFilesOnExit);
    final File outputFile2 = TestData.temp(this, "SProfile2-.jp2", deleteTempFilesOnExit);
    // //
    // Preparing to read
    // //
    final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", inputFile);
    if (ENABLE_SUBSAMPLING) {
        ImageReadParam readParam = new ImageReadParam();
        readParam.setSourceSubsampling(4, 4, 0, 0);
        pbjImageRead.setParameter("readParam", readParam);
    }
    pbjImageRead.setParameter("Reader", new JP2GDALKakaduImageReaderSpi().createReaderInstance());
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (1ST version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile1));
    ImageWriter writer = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite.setParameter("Writer", writer);
    // Specifying image source to write
    pbjImageWrite.addSource(image);
    ImageWriteParam param = writer.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param).setSProfile(1);
    pbjImageWrite.setParameter("writeParam", param);
    // Writing
    final RenderedOp op = JAI.create("ImageWrite", pbjImageWrite);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (2ND version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite2 = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite2.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile2));
    ImageWriter writer2 = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite2.setParameter("Writer", writer2);
    // Specifying image source to write
    pbjImageWrite2.addSource(image);
    ImageWriteParam param2 = writer2.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param2).setSProfile("PROFILE2");
    pbjImageWrite2.setParameter("writeParam", param2);
    // Writing
    final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
Also used : ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) ImageWriter(javax.imageio.ImageWriter) FileImageOutputStreamExtImpl(it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl) ImageWriteParam(javax.imageio.ImageWriteParam) File(java.io.File) Test(org.junit.Test)

Example 5 with FileImageOutputStreamExtImpl

use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.

the class JP2KWriteTest method write_COMSEG.

// ////////////////////////////////////////////////////////////////////////
// 
// Testing "COMSEG" Create Option.
// 
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_COMSEG() throws IOException, FileNotFoundException {
    if (!isJp2KakDriverAvailable)
        return;
    LOGGER.info("Testing JP2 Write operation with COMSEG option setting");
    // //
    // Preparing input/output files
    // //
    final File inputFile = TestData.file(this, testFileName);
    Assert.assertTrue(inputFile.exists());
    // Output files resulting from 2 different values of the same create
    // option. In this test, the create option is COMSEG.
    final File outputFile1 = TestData.temp(this, "COMSEG-.jp2", deleteTempFilesOnExit);
    final File outputFile2 = TestData.temp(this, "NO-COMSEG-.jp2", deleteTempFilesOnExit);
    // //
    // Preparing to read
    // //
    final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", inputFile);
    if (ENABLE_SUBSAMPLING) {
        ImageReadParam readParam = new ImageReadParam();
        readParam.setSourceSubsampling(4, 4, 0, 0);
        pbjImageRead.setParameter("readParam", readParam);
    }
    pbjImageRead.setParameter("Reader", new JP2GDALKakaduImageReaderSpi().createReaderInstance());
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (1ST version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile1));
    ImageWriter writer = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite.setParameter("Writer", writer);
    // Specifying image source to write
    pbjImageWrite.addSource(image);
    ImageWriteParam param = writer.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param).setComseg("YES");
    pbjImageWrite.setParameter("writeParam", param);
    // Writing
    final RenderedOp op = JAI.create("ImageWrite", pbjImageWrite);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (2ND version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite2 = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite2.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile2));
    ImageWriter writer2 = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite2.setParameter("Writer", writer2);
    // Specifying image source to write
    pbjImageWrite2.addSource(image);
    ImageWriteParam param2 = writer2.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param2).setComseg("NO");
    pbjImageWrite2.setParameter("writeParam", param2);
    // Writing
    final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
Also used : ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) ImageWriter(javax.imageio.ImageWriter) FileImageOutputStreamExtImpl(it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl) ImageWriteParam(javax.imageio.ImageWriteParam) File(java.io.File) Test(org.junit.Test)

Aggregations

FileImageOutputStreamExtImpl (it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl)21 File (java.io.File)21 ImageReadParam (javax.imageio.ImageReadParam)20 ImageWriteParam (javax.imageio.ImageWriteParam)20 ImageWriter (javax.imageio.ImageWriter)20 ParameterBlockJAI (javax.media.jai.ParameterBlockJAI)20 RenderedOp (javax.media.jai.RenderedOp)20 Test (org.junit.Test)20 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1