Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
That should work. As you are using JPG (not a good idea as JPG is inexact) you do not have any matte channel to remove before the composition. As such the CopyOpacity composition should use the source image as a greyscale mask.
What does "identify" say about the result?
Have you tried it with PNG to see if that produces transparency?
Can you give us some example images where it is failing?