Probably easiest with a Photoshop script. Both palette and sample from image would need to be in the same color space with assuarance the image was taken its color data values are known to be accurate.
Script would include a table of the palette
User specifies which data elements to be included in comparison (e.g. "L" and/or "a" and/or "b" in Lab space) and then the script does an RMS (root mean square) comparison to each palette element in the table and provides which one has the minimum differential or the closest match.
Note that what is mathematically the closest is not what is always visually the closest so one might have to have a scaling factor on the the separate L,a,b components. This could be done for any color space not just Lab.
Again, per my other post, these are simple questions to a relatively straightforward question you have yet what you need in the overall large major software development program is probably something totally different.
Keep in mind that Photoshop might be the square peg you are trying to fit in the round product hole. Just my opinion.
Hope this incremental information is helpful.