Free Support Forum - aspose.com

resizeWidthProportionally with Java doesn't resize image but crops it instead

Hello,
i try to resize an existing image (no matter if jpg or gif, same issue) forcing width to 400px with proportional height
Final result has good size but it is a crop of the upper left angle of my source image instead of smaller image. I copied code from delivered aspose example.

    Image image = Image.load(inputPath);

    if (!image.isCached()) {
        image.cacheData();
    }

    System.out.println("Starting resize of " + inputPath + " (" + image.getWidth() + "x" + image.getHeight() + ") to " + width + "px width...");
    image.resizeWidthProportionally(width);

    // saving result
    //image.save(outputPath, new JpegOptions());
    image.save(outputPath);
    System.out.println("File resized into : " + outputPath + " (" + image.getWidth() + "x" + image.getHeight() + ")");

I am using JDK 8
What could be wrong ?
Thank you for your help

Michel

@mcharpentier

I suggest you to please try using the example code given over following thread link. If there is still an issue then please share the source file and generated output with us that is reproducing the issue.

I am using the Aspose delivered example : https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/src/main/java/com/aspose/imaging/examples/ModifyingImages/ResizeImageProportionally.java

original.jpg (143.5 KB)
expected_output.jpg (16.9 KB)
aspose_resized_output.jpg (3.8 KB)

And this example doesn’t work for me.
When i load image (original.jpg) then call “image.resizeWidthProportionally(400);”, it crops the image (see aspose_resized_output.jpg) instead of resizing it (expected_output.jpg)

I guess it is very easy to reproduce ( i use aspose-imaging-20.12-jdk16.jar)

@mcharpentier

I have created an issue with ID IMAGINGJAVA-7800 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.