There is no generals solution for what you want to do. A clipping mask layer layer's bounds can have aspect ratio and the pixel content within the layers bounds can be any shape. Only layer that have identical Aspect ratio and pixel content shape can bet size to fit perfectly. Raster shapes do not scale perfectly either rectangle may. All other you need to design some resizing method to produce some results you can live with.
In my Collage scripts I do not use layer to clip images to. Instead my templates contain Alpha channels that map the collages Image locations, sizes and shapes. So in effect my Alpha channels are like clipping layers. My collage scripts place in images and changes the Smart object layers Place Transform to fill the bounds of an alpha channel and aligns the smart object to the center of the alpha channels bounds then uses the Alpha channel to mask the smart objects to shape.