Unable to Convert Color Image to Grayscale Using Aspose.Slides for Java

Hello Aspose Support Team,

I am currently working on a project where I need to convert a color image to grayscale within a presentation slide using Aspose.Slides. Despite my efforts, I have been unable to achieve the desired result using the code provided below. I am seeking your assistance to identify if there is an alternative approach or if I am missing something in my implementation.

Version
Aspose.Slides Version: 23.3 (jdk16)

Code

InputStream imageStream = fetchUserImage(token, emp.getHrid());

IPPImage image = pres.getImages().addImage(imageStream);

// Add image with selected shape
IShape imageComponent = addImageWithShape(slide, shape, image_x, image_y, image_box_length, image_box_breadth, image);

if (grayScale) {
    log.info("Converting image to grayscale");
    imageComponent.setBlackWhiteMode(BlackWhiteMode.BlackGray);
}

// Set the green color border
ILineFormat lineFormat = imageComponent.getLineFormat();
lineFormat.getFillFormat().setFillType(FillType.Solid);
lineFormat.getFillFormat().getSolidFillColor().setColor(greenColor);

@navedkhan1308,
Thank you for contacting support.

Unfortunately, I cannot use your code snippet to check the problem you described. Please share the following files and information:

  • sample presentation file
  • complete standalone code example
  • output file with the desired result