General questions

How to set the size of the return image

Hello MyScript,


How can I set the dimensions of the image to be returned from MyScript via the API?

I am following this guide: https://swaggerui.myscript.com/#/batch-mode-controller/batchUsingPOST

I thought the width and height parameters in the request body would work, but I got back a much smaller image with different dimensions. Then I looked at "ExportConfiguration", but I only see a parameter for resolution taking a single integer, not dimensions such as in the form of (224, 224).


Thank you for your time,

Tyson


Dear Tyson,


Thank you for contacting us!


The width and height parameters in the request body correspond indeed to the size of the writing area, not to the size of the exported image. (for details see https://developer.myscript.com/docs/interactive-ink/1.3/web/rest/architecture/#setting-the-size-of-the-writing-area)


For the moment, there is no API to set the image size in the form of (224, 224). But you might give a try to the image resolution taking a single integer, that will enable you to modify the size (image resolution) of the exported image, keeping the scale. For instance, assuming your content is math, you could use following configuration:


{"contentType": "Math",
"configuration" :
{
"export":
{
"image-resolution": 500
}
},
"strokeGroups": [ ....]

}


Best regards,


Gwenaëlle

Thank you Gwenaelle for the quick response and detailed reply.


I tried setting the export image-resolution but the dimensions and scale still change. I set a drawing area of 512x512 and an image-resolution of 500. The image I got in response was 227x756, so this is not something I could just scale up or down. The shape of the output seems to be conforming to the shape of the strokes (instead of the drawing area) and adding some unknown amount of white space to each side. The output dimensions seem to be the same no matter if I set the output type to image, SVG, or PowerPoint, so I've been testing it with images for ease of testing purposes. By the way, I am using a contentType of Diagram if that makes any difference.

I would like to eventually be able to overlay the result returned from the API on top of the original (I am extracting line coordinates from an image and sending those to the API, since it doesn't seem to accept images directly). I would like an output type where I can easily adjust the returned strokes within an Office application such as PowerPoint, so an ideal output type is PowerPoint format. Second best would be SVG.

Can you think of any way in which I could accomplish this goal? It looks like it should be possible judging from the web demo version, but I can't figure out how to do it.


Thank you for your time,

Tyson

Dear Tyson,


Thank you for your update.


If you want to get the recognition result in a PowerPoint format, you should use following format in the request header:   'Accept: application/vnd.openxmlformats-officedocument.presentationml.presentation,application/json'

This export format is available only for Diagram, and the exported result is typeset. So, you won't have the original ink and I guess it will be difficult to match with your original image.


Another option you might consider if what you want is overlapping the handwritten ink with the recognized typeset is sending twice your strokes and get the result as svg ( header 'Accept:image/svg+xml,application/json')

once with the original ink, and once with typeset content, with same option except the conversion state.

 In order to get the typeset result: 

{"contentType": "Diagram",
"conversionState":"DIGITAL_EDIT",
"strokeGroups": [ ... ] }


Best regards,


Gwenaëlle


Dear Gwenaelle,


Thank you.

I have been testing the PowerPoint format. It works very well.

Thank you for teaching me about how to get an unedited version back from the API. I did not know about that and just gave it a test run. This could be useful in a situation where we would want to convert strokes straight to SVG or PowerPoint format without detections. I will keep it in mind.

Without being able to match the output shape to the shape of our input image, I think it will be difficult to utilize MyScript for our client's particular use-case this time. However I am very impressed by this service and will keep it in mind for future projects.

Thank you,

Tyson

Dear Tyson,


thank you for this update.


Feel free to contact us if you happen to need our technology in your future projects.


Best regards,


Olivier