How can I lower the quality and size of an image in base64
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 10:48 AM
I am creating a pdf and the images uploaded by the end users are of high quality, (3megas) I cannot restrict the user from lowering the quality, the image travels through the json in base64, how can I lower the quality?
var foto2 = tablaDanios2.sys_id;
var tablaAttachment2 = new GlideRecord('sys_attachment');
tablaAttachment2.addQuery('table_sys_id', foto2);
tablaAttachment2.query();
while (tablaAttachment2.next()) {
var sa2 = new GlideSysAttachment();
sa2.getContent(tablaAttachment2);
var encodedData2 = sa2.getContentBase64(tablaAttachment2);
gs.addInfoMessage(encodedData2);
json_body += encodedData2 ;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 11:00 AM
Hello,
Not really sure what you mean by the image travels through the JSON in base64, unless you mean they load it somewhere else...?
If they're loading it in ServiceNow and you know where they're doing it (if via catalog item, etc.), then you could try and bake-in a process to handle it there.
In either case, you wouldn't be able to just change a few characters to accomplish this...most, if not all solutions involve taking the base64, loading it in a canvas, making the tweaks to it (lowering resolution or whatever) and then grabbing the new base64 for use.
This is going to be a bit more complex...so if you're not a developer or don't understand code very well, you'll probably want to get with a peer for assistance.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!