Rewrite Image -> Duplicate to work with layers

One of the great things about PD's Layers rewrite is that it forced me
to rework a lot of the existing codebase, which in turn gave me an
excuse to clean-up some of PD's oldest infrastructure bits.  The new
infrastructure makes it much easier for me to do complex things (like
duplicate an image).

Anyway, the new "Duplicate Image" function is significantly smaller than
the old one, but with much better performance and elegance.  It also
supports full duplication of multilayered images.
Write null padding trim function for layers

This is key to fixing the Image menu.

One of the big difficulties with Layers support is how to apply
image-wide transforms.  Some software outright disallows this (for
example, GIMP does not allow arbitrary rotation without first flattening
an image) because of the nasty math involved.  But PD is better than
that!

My solution is as follows: before applying an image-wide transform, like
"rotate image", we must first pad all layers with transparent pixels so
that they are the size of the full image.  Then, apply the
transformation to each layer individually.  When the transformation is
complete, auto-crop all layers using this new "null padding trim"
function.  (In effect, look for fully transparent rows and columns, and
remove them from the image.)

My approach provides a universal way to process any full-image
transforms, without needing ugly custom-transform code for each
transformation.  Hopefully this means I can get the Image menu back in
working order sooner rather than later...
Rewrite Image -> Flip horizontal/vertical to support layers

Technically, these functions are simple enough that they could be
written using custom math.  However they provided an easy way to test
the new null-padding layer transformation system - which works
beautifully!