Free Trial
10 days, no credit_card

<< More Tutorials

How to resize an image by width and height in Java using rethumb?

To resize an image or photo in Java use the following code:

import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;

public class JavaRethumbExample
    public static void main(String [] args) throws Exception
        String paramOperation1 = "height";
        int paramValue1 = 100; // New height in pixels.

        String paramOperation2 = "width";
        int paramValue2 = 100; // New width in pixels.

        String imageURL = "";
        String imageFilename = "resized-image.jpg";

        URL url = new URL(String.format("", paramOperation1, paramValue1, paramOperation2, paramValue2, imageURL));
        FileOutputStream fos = new FileOutputStream(imageFilename);
        fos.getChannel().transferFrom(Channels.newChannel(url.openStream()), 0, Long.MAX_VALUE);

Start using this example now

Use the following commands to get started:

$ git clone
$ cd rethumb-java-examples
$ ... Use your IDE of choice to handle the file ""

More examples using Java