Closed tbrouard closed 2 months ago
The type passed to the asImage() service is used to tell M2Doc the format of the image if it can't be computed from the file extension. It's not used to convert the image format. To do that, you can create a Java service and use javax.imageio.ImageIO for instance.
And Yes the documentation is wrong...
I'm submitting a...
Current behavior
Using the method "asImage()" of the M2doc ImageServices.java class to export images in my word doesn't seem to be converting the format as described in the example provided in the documentation of the method. I watch the method call using the debug view and watch the values of the different parameter. The behavior appears to be the following :
The image is exported but the extension, therefore its format, is never changed. The type parameter is just stored in the attribut of the MImageImpl class.
Expected behavior
From what I understood of the documentation of the method it should change the format of the image from the original to the expected one. (From line 79 to 93 of the ImageServices.java class)
Minimal reproduction of the problem with instructions
I used in my word template this line :
{m: 'name_of_my diagram_picture.png'.asImage('jpg')}
Then looked at the format of the image put in my generated word : it's still '.png'What is the motivation / use case for changing the behavior?
I would be interested in changing my images format into 'EMF' format since it is in the list of format that might be available in the PitcureType.java class. I would be also keen on information about how image exporting methods work as i might not have well understand them. Thanks
Environment