# Forums

Math

## REST Math recognition with image/png, image/jpeg and text/html return image of my strokes, not the converted math.

Hello.

I am using iinkjs with the REST protocol with the MATH recognition type and  am trying to obtain an image I can insert onto our FabricJS canvas. However, with image/png, image/jpeg and text/html, I get an image of the strokes used for the recognition, not the converted math.

Here is an image of the strokes. I gather points from the strokes and to fill the strokeGroups with.

Here is what I get for the image/png format in the recognize callback:

When I ask for mathml or latex, I get what is expected:

<math xmlns='http://www.w3.org/1998/Math/MathML'>
<mtable columnalign='left'>
<mtr>
<mtd>
<mn> 2 </mn>
<mo> + </mo>
<mi> x </mi>
<mo> = </mo>
<mn> 7 </mn>
</mtd>
</mtr>
<mtr>
<mtd>
<msqrt>
<mn> 49 </mn>
</msqrt>
</mtd>
</mtr>
</mtable>
[/itex]


Should I be getting an image of the converted math or is this as expected.

I have also used MathJax to convert the mathml to an image and that works, but feel it shouldn't be necessary.

Thanks.

Dear "Devteam",

thank you for the update.

At present, using the iinkJS, the solution would consist in patching the "post" functionof the src/recognizer/rest/networkInterface.js file:

export async function post (recognizerContext, url, data, apiVersion, mimeType) {
const configuration = recognizerContext.editor.configuration
const recognizerContextRef = recognizerContext
if (recognizerContextRef) {
recognizerContextRef.idle = true
}
try {

Replacing application/json by "image/png" should normally work.

Instead, I would recommend you format the REST request by yourself, setting the "Accept" header as in the above image ; it would be easier and faster.

Best regards,

Olivier

1 person likes this

Dear "Devteam",

thank you for contacting us.

Currently, for the REST API, you can create a simple request, referring to our swaggerui page: https://swaggerui.myscript.com/

Simply setting the Accept header to "image/png" will normally return an image.

Best regards,

Olivier

Hmm, I thought just setting the mime type in the recognizer configuration would be enough. I can try this as well.

Hi,

I forgot to mention that I am using iinkJS to do the rest call as shown in the rest_no_ui.html example. How would I go about setting the accept header using iinkjs' export_ call? I would have thought iinkJS would do that for me.

Thanks.