Error in replacing image from Aspose.slide java

Error :-
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.aspose.slides.ms.core.System.Drawing.imagecodecs.jpeg.oracle.OracleJpegImageReader (file:/home/prdxn70/.m2/repository/com/aspose/aspose-slides/19.7/aspose-slides-19.7-jdk16.jar) to field com.sun.imageio.plugins.jpeg.JPEGImageReader.colorSpaceCode
WARNING: Please consider reporting this to the maintainers of com.aspose.slides.ms.core.System.Drawing.imagecodecs.jpeg.oracle.OracleJpegImageReader
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
--------------------------------------------------------------------------------------
Problem 1:- I have created pptx and I am having 2 same image in one slide. as I am trying to replace one image both the image get replaced and it throws above WARNING message.

Problem 2: I have created pptx and it has 2 image after some time I have added 3rd image at the 2nd position and I am trying to replace it. It is replacing image at the 3rd position.

do have solution to this problem??

Thanks
Saquib s.

@saquibs,

Can you please accept my source file access request so that i may further investigate to help you out.

Yup Accepted… Thanks In advance.

@saquibs,

I have observed the presentation file shared by and it seems to be generated presentation. First of all, I request you to please provide the source presentation along with working sample code used on your end that we may test in our environment to reproduce the issue.

Now, coming to your following problem:

This is not an issue. Actually, the images in presentation are in fact added in presentation image collection. So, if you add two similar images, the API keeps only one out of them and avoid duplicity. So, two or more shapes if share same image then on back end there is single image in Image collection for them. Also, when you add image to presentation, you first add image to ImageCollection and then you associate that added image to one or more shapes as desired. So, this is not an issue and if you want to have this approach then your images must be slightly differing. Otherwise, Aspose.Slides will treat them as similar image. So when you will change the image then all shapes associated with that image will have replaced image. Its not an issue.

Please share the source files, used sample code, generated presentation and desired output presentation for this. We will investigate that on our end on provision of requested information.

I have updated the above link you can access another PPTX file named as “pres2.pptx”. try to replace image at the Third position it replace image at the second position.

String dataDir = “/home/prdxn70/eclipse-workspace/ppt/src/main/resources/com/demo/ppt/App/”;
try {
//Instantiate the presentation
Presentation presentation = new Presentation(dataDir + “pres2.pptx”);

//Read image from source
File file = new File(dataDir + "img2.png");
byte[]data = new byte[(int) file.length()];

InputStream inputStream = null;

try	{
	inputStream = new FileInputStream(file);
	inputStream.read(data);
} finally {
	inputStream.close();
}
//Code for replace Image
IPPImage oldImage = presentation.getImages().get_Item(2);
oldImage.replaceImage(data);

//Save the presentation
presentation.save(dataDir + "HelloWorld5.pptx", SaveFormat.Pptx);

} catch (Exception e) {
System.out.println(e);
}

@saquibs,

I have tried to access the above link and it seems, I don’t have permission for above link. Can you please grant me access to file.

Access granted… Plzz check
Thanks!!

@saquibs,

I have worked with source file shared by you using Aspose.Slides for Java 19.7 and unable to observe issue. I have also shared my generated result with you for your kind reference. Can you please share environment details with us. HelloWorld5.zip (1.1 MB)

I am using Eclipse and javac 11.0.4 and Aspose.Slides for Java 19.7. I am using OS linux mint. PowerPoint slide reader is LibreOffice Impress. can I know which OS and slide reader you r using? Because I think it is a problem of LibreOffice Impress which I am using. the storing pattern is different from PPTX slides. it uses .odp format. please check that too.

THANKS.
Saquib.

@saquibs

I am using windows 10 and PP 2016 on my end to verify files.

I guess problem is with LibreOffice Impress…

@saquibs,

I am unable to understand the above points. We have verified using Windows environment on our end and it does not depend on that as you are simply performing image replacement inside presentation. Have you observed the presentation that we have generated using your sample code on our end.