Java slides � Need code to change height/width of image (without losing quality) before adding it to shape

Hello Team,

Could you guys please let me know how can I change image height/width before adding it to Rectangle shape? We’ve images of random sizes and need approach to expand/shrink images height/width before adding those to rectangle shape without losing their quality. Currently I am using below code in which I am using “PictureFillMode.Stretch” option to fit image but it’s kind of reducing image quality.

IShape shp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 540, 10, 170, 60);

//shp.getFillFormat().getSolidFillColor().setColor(Color.WHITE);

//Set the fill type to Picture
shp.getFillFormat().setFillType(FillType.Picture);

//Set the picture fill mode
shp.getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);

//Set the picture
IPPImage imgx = null;
try {
    imgx = pres.getImages().addImage(new FileInputStream(new File("Logo.jpg")));
} catch (IOException e) {
}

shp.getFillFormat().getPictureFillFormat().getPicture().setImage(imgx);

Please advise!

Regards,
Pavan

Hi Pavan,

Thank you for making separate posts for separate issues.

I have observed your comments and like to share with you that Aspose.Slides does not provide any feature to work with images. You may look for some third party tool or Aspose.Imaging component to expand/shrink images height/width as per your requirements.

Please share if I may help you further in this regard.

Best Regards,