Package com.alibaba.simpleimage.render

Examples of com.alibaba.simpleimage.render.ScaleParameter


        try {
            inputStream = ImageUtils.createMemoryStream(inputStream);
            output = new ByteArrayOutputStream();
            ImageFormat outputFormat = ImageUtils.isGIF(inputStream) ? ImageFormat.GIF : ImageFormat.JPEG;
            ScaleParameter scaleParam = new ScaleParameter(maxWidth, maxHeight, Algorithm.AUTO);

            ImageRender rr = new ReadRender(inputStream, true);
            ImageRender dtr = new DrawTextRender(rr, drawParam);
            ImageRender sr = new ScaleRender(dtr, scaleParam);
            wr = new WriteRender(sr, output, outputFormat);
View Full Code Here


    void doScaleWork(File in, boolean toRGB, File out, ImageFormat format) throws Exception {
        WriteRender wr = null;
        InputStream inStream = new FileInputStream(in);
        try {
            ReadRender rr = new ReadRender(inStream, toRGB);
            ScaleRender sr = new ScaleRender(rr, new ScaleParameter(100, 100));
            wr = new WriteRender(sr, out, format);
           
            wr.render();
        } finally {
            IOUtils.closeQuietly(inStream);
View Full Code Here

        ImageWrapper wmImage = null;
        ImageRender sr = null;
        try {
            in = new FileInputStream(new File(path, "alibaba1.gif"));
            rr = new ReadRender(in, false);
            sr = new ScaleRender(rr, new ScaleParameter(width, height, ScaleParameter.Algorithm.SUBSAMPLE_AVG));
            wmImage = sr.render();
        } finally {
            if (sr != null) {
                sr.dispose();
            }
View Full Code Here

        String[] imgNames = { "color.jpg", "334.jpg", "sawtooth.jpg", "airport.jpg", "4.jpg", "6.jpg", "7.jpg",
                "8.jpg", "9.jpg", "IMG_0033.jpg" };
        for (String imgName : imgNames) {
            File in = new File(dir, imgName);
            File out = new File(resultDir, "LANCZOS_" + getShortname(imgName) + "_java_lanczos_1024_result.jpg");
            ScaleParameter scaleParam = new ScaleParameter(1024, 1024, Algorithm.LANCZOS);
            doScale(in, out, scaleParam);
        }
    }
View Full Code Here

    public void testQuailty2() throws Exception {
        String[] imgNames = { "st.jpg", "yuan.jpg" };
        for (String imgName : imgNames) {
            File in = new File(dir, imgName);
            File out = new File(resultDir, "LANCZOS_" + getShortname(imgName) + "_java_lanczos_300_result.jpg");
            ScaleParameter scaleParam = new ScaleParameter(300, 300, Algorithm.LANCZOS);
            doScale(in, out, scaleParam);
        }
    }
View Full Code Here

    }

    public void testScaleGIF() throws Exception {
        File gif = new File(dir, "box_disapper.gif");
        File dest = new File(resultDir, "LANCZOS_box_disapper_java_lanczos_result.gif");
        ScaleParameter scaleParam = new ScaleParameter(310, 310, Algorithm.LANCZOS);
        doScale(gif, dest, scaleParam, ImageFormat.GIF, true);
    }
View Full Code Here

    }

    public void testPNG() throws Exception {
        File png = new File(dir, "rings.png");
        File dest = new File(resultDir, "LANCZOS_rings_java_lanczos_result.jpg");
        ScaleParameter scaleParam = new ScaleParameter(310, 310, Algorithm.LANCZOS);
        doScale(png, dest, scaleParam);

        png = new File(dir, "a.png");
        dest = new File(resultDir, "LANCZOS_a_java_lanczos_result.jpg");
        scaleParam = new ScaleParameter(832, 1176, Algorithm.LANCZOS);
        doScale(png, dest, scaleParam);
    }
View Full Code Here

    }
   
    public void testScaleGray() throws Exception {
        File gif = new File(dir, "gray.jpg");
        File dest = new File(resultDir, "LANCZOS_gray_java_lanczos_result.jpg");
        ScaleParameter scaleParam = new ScaleParameter(310, 310, Algorithm.LANCZOS);
        doScale(gif, dest, scaleParam, ImageFormat.JPEG, false );
    }
View Full Code Here

    }

    public void testScaleCMYK() throws Exception {
        File cmyk = new File("./src/test/resources/conf.test/simpleimage/cmyk/cmyk_noprofile_1.jpg");
        File dest = new File(resultDir, "LANCZOS_cmyk1_java_lanczos_result.jpg");
        ScaleParameter scaleParam = new ScaleParameter(512, 512, Algorithm.LANCZOS);
        doScale(cmyk, dest, scaleParam, ImageFormat.JPEG, false);
       
        cmyk = new File("./src/test/resources/conf.test/simpleimage/cmyk/cmyk_noprofile_2.jpg");
        dest = new File(resultDir, "LANCZOS_cmyk2_java_lanczos_result.jpg");
        doScale(cmyk, dest, scaleParam, ImageFormat.JPEG, false);
View Full Code Here

   
    public void testScaleBounds() throws Exception {
        File img = new File(dir, "color.jpg");
        for (int i = 1; i < 32; i++) {
            File dest = new File(resultDir, "LANCZOS_color_java_lanczos_" + i + "_result.jpg");
            ScaleParameter scaleParam = new ScaleParameter(i, i, Algorithm.LANCZOS);
            doScale(img, dest, scaleParam);
        }

        for (int i = 31; i < 150; i += 8) {
            File dest = new File(resultDir, "LANCZOS_color_java_lanczos_" + i + "_result.jpg");
            ScaleParameter scaleParam = new ScaleParameter(i, i, Algorithm.LANCZOS);
            doScale(img, dest, scaleParam);
        }

        for (int i = 1000; i <= 2000; i += 100) {
            File dest = new File(resultDir, "LANCZOS_color_java_lanczos_" + i + "_result.jpg");
            ScaleParameter scaleParam = new ScaleParameter(i, i, Algorithm.LANCZOS);
            doScale(img, dest, scaleParam);
        }
    }
View Full Code Here

TOP

Related Classes of com.alibaba.simpleimage.render.ScaleParameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.