logo

New Response

« Return to the blog entry

You are replying to:

    • avatar
    • Kjetil Fossum
    • Posted on Wed 4 Jan 2012 06:44 AM

    Hi Jake, first of all - I really enjoy reading your Blogs, thank you!

    I've seen this error running similar Java code (resizing JPEGs) on my sites. It has probably to do with the increasing size of filesize on the JPEGs being uploaded. I tried different approaches to solving this (JAI and other libs). But at last I solved this by using Imagemagick installed on the serverside (I don't know if you have the possibility to install software on the server?) . I'm uploading the files to a servlet (uploading multiple files at once) and resizing them with Imagemagick before reattaching them to the document in the wQS agent.

    Code snippet from servlet:

    private static boolean convert(File in, File out, int width, int height, int quality) {

    if (quality < 0 || quality > 100) {

    quality = 75;

    }

    ArrayList command = new ArrayList(10);

    command.add("C:\\ImageMagick\\convert");

    command.add("-scale");

    if (width == 0) {

    command.add(" "+height + "%");

    }

    else {

    command.add(" "+width + "x" + height);

    }

    command.add("-quality");

    command.add(" " + quality);

    command.add(in.getAbsolutePath());

    command.add(out.getAbsolutePath());

    return exec((String[])command.toArray(new String[1]));

    }

    Hope this can be of help :-)

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: