compare 2 image based on based64 byte array

artur11
Kilo Contributor

Hello my friends,

In my current project I got some issue with Helsinki.

I want to compare 2 image using byte array (based64) in Geneva instance and it is working fine but after upgrade to Helsinki this same code didn't work... Have you got similar problems ?

Attachment is a Glide Record to sys_attachment;

var att = Attachment.sys_id;

var binData = new GlideSysAttachmentInputStream(att);

var atm = '';

var bytearrayOS = new Packages.java.io.ByteArrayOutputStream();

binData.writeTo(bytearrayOS);                                                                                                                                                                           <-- in this i got problem

atm = GlideBase64.encode(bytearrayOS.toByteArray());

Maybe you have other methods to compare 2 images ?

Best regards,

Artur

4 REPLIES 4

Chuck Tomasi
Tera Patron

Hello Artur,



Take a look at the GlideSysAttachment() API. It contains updated methods to get your content in base64. I was working with it a bit last week, but ultimately my work went in another direction and I ended up note using it. It might prove more compatible than the legacy/deprecated Packages calls.


Thanks for answer



I try GlideSysAttachment.getContentBase64(<record sys_id>); and didn't work either


Rohant Joshi2
Kilo Expert

var StringUtil = GlideStringUtil;


var gsa = new GlideSysAttachment();



StringUtil.base64Encode(gsa.getBytes(gr))



For converting image to base64 you can use above method, but not sure if you were able to figure out way to compare Base64 encoded data for two images.



Regards,


Rohant


Hi Rohant,


Thx for answer, I make workaround but I will check your solution later.


Problem was that every single imgae was attach to attachment in ticket. When we got many sends and answer on this same email (conwersation) we got same image many times. This example is for footers.