Something has changed with layers or page?
Posted: 2013-12-28T04:42:49-07:00
I have some code that used to work and now it has stopped and I hope somebody can explain the problem.
If you look at this image the part that should be on the right hand side is on the left hand side. Altering the value of page has no effect it is always in the same place.

This seems to be the problem line:
This is the full code:
Version 6.8.5 Q16 on Windows 7
If you look at this image the part that should be on the right hand side is on the left hand side. Altering the value of page has no effect it is always in the same place.

This seems to be the problem line:
Code: Select all
// Join the images
$cmd = " ( -page -1,0 top_edge.miff -page +0+$alpha center.miff -page +$tweek+0 right_edge.miff -background none -layers merge ) ".
" ( +clone -background black -shadow 80x4+4+4 ) +swap -background none -layers merge +repage ";
Code: Select all
<?php
// Input image
$image = '1.jpg';
// Resize to a png to stop quality loss
exec("convert $image -thumbnail 500x500 temp.png");
// Get the size of the original image
$size = getimagesize('temp.png');
// The canvas frame edge
$edge = $size[0]*.06;
// New central portion width
$width = $size[0] - ( $edge * 2 );
// New central portion height
$height = $size[1] - ( $edge * 2 );
// Reduction of edge width
$shrink = round(( $edge * 0.6 ), 2);
// Angle of the edge
$angle = 45;
// Change in edge height
// Convert angle to radian > angle in degrees * Pi / 180
$radian = ( $angle * Pi() ) / 180;
$alpha = round((abs(tan($radian)) * $shrink), 2);
// Edge short side
$short_side = round( ($height - $alpha ), 2);
// Top long side
$top_long = round($width + $shrink, 2);
// Crop for the edges
$cmd = " temp.png ( -clone 0 -crop {$width}x{$height}+{$edge}+{$edge} +repage -write center.miff +delete )".
" ( -clone 0 -crop {$width}x{$edge}+$edge+0 +repage -write top.miff +delete )".
" -gravity northeast -crop {$edge}x{$height}+0+{$edge} +repage -write right.miff +delete null: ";
exec("convert $cmd ");
// Perspective for the RHS
$cmd = " right.miff -virtual-pixel background -background none ".
" +distort Perspective \"0,0 0,0 $edge,0 $shrink,-$alpha $edge,$height $shrink,$short_side 0,$height 0,$height\" +repage -trim";
exec("convert $cmd right_edge.miff");
// Perspective for the top
$cmd = " top.miff -virtual-pixel background -background none ".
" +distort Perspective \"0,0 $shrink,0 $width,0 $top_long,0 $width,$edge $width,$alpha 0,$edge 0,$alpha\" +repage -trim";
exec("convert $cmd top_edge.miff");
// There was a 1px gap between the RHS and main photo
$tweek = $width-1;
// Join the images
$cmd = " ( -page -1,0 top_edge.miff -page +0+$alpha center.miff -page +$tweek+0 right_edge.miff -background none -layers merge ) ".
" ( +clone -background black -shadow 80x4+4+4 ) +swap -background none -layers merge +repage ";
exec(" convert $cmd canvas1.png");
// Display the final image
echo "<img src=\"canvas1.png\">";
// Alternative style
$cmd = " canvas1.png -virtual-pixel background -background none ".
" +distort Perspective \"0,0 0,-40 962,0 962,0 962,602 962,602 0,602 0,562\" +repage -trim";
exec("convert $cmd canvas2.png");
// Display the final image
echo "<img src=\"canvas2.png\">";
// Cleanup
foreach ( glob("*.miff") as $filename ) { unlink($filename); }
?>