I am trying to shear an image and place on another image, like a photo on a cake, I am working in Perl and using Image::Magick Perl library. Here is the output I am able to generate, I am unable to make the background of the sheared image. Here's my code:
#!/usr/bin/perl
use strict;
use warnings;
use Image::Magick;
my $im = Image::Magick->new;
$im->Read('cake.jpg');
$im->Scale('50%');
my $sh = Image::Magick->new;
$sh->Set( magick => 'png' );
$sh->Read('oo.jpg');
$sh->Resize(width => 580, height => 540);
$sh->Shear( geometry => '580x540+0+0', x => -40, y => -30, 'virtual-pixel' => 'Transparent');
$im->Composite( image => $sh, geometry => '+90+60');
$im->Write('test.jpg');
Also, I have seen some posts using AffineTransform, but using those I am unable to achieve the shear.
I solved it by creating a mask ( by inverting alpha channel ). Here's the code, hope this helps someone:
Final image: