Have different spritesheets for every weapon-component you load as separate image resources. When you want to draw a character, you first draw the character-sprite, and then the sprites of each weapon-component, one after another.
Keep in mind that in some cases it might be necessary for some parts to change the drawing offsets of other parts. You might, for example, have a silencer-part which fits on the barrel of a pistol, carbine or sniper rifle. You can use the same sprite for each, but would have to draw it at different positions depending on how the barrel-part of the gun looks. That means each barrel-part would need an additional property which says where a muzzle-part would need to be drawn. Or maybe the weapon has multiple barrels. That would mean multiple silencers would have to be drawn with different offsets (Silenced gatling gun? Why not?).
Should performance be a concern, you could use sprite-batching as a performance enhancement. Sprite-batching means to draw each animation phase with all the sub-sprites to an off-screen image and then draw the actual game using that off-screen image as a source. That way, when you have a sprite consisting of 5 sub-sprites, you only need to do one draw-call per frame and not 5. However, converting that off-screen image into a graphic file and saving it somewhere is of little use. Just keep it in the native texture format of the graphic API you are using. The only use I could think of would be to save the complete spritesheet together with the savegame to speed up savegame loading. But considering that we are talking about a 2d game here, I doubt that this optimization would be worth the effort.
Whether or not that library fits your requirements is a technology-question, and what-technology-to-use questions are off-topic here because they are usually subjective.