i'm editing code chmod 777 and all create file (.miff)Bonzo wrote:I pressume you can get simple Imagemagick commands to work like a straight forward resize?
Have you changed the permissions on the folder you are saving to - 777 or 755
It looks like the code is failing here:The standard output from ImageMagick is 0 for sucsesful image generation and 1 for a failure.Code: Select all
// Crop for the edges $cmd = " temp.png -clone 0 -crop ".$width."x".$height."+".$edge."+".$edge." highlights.miff -composite -write center.miff +delete ". " -clone 0 -crop ".$width."x".$edge."+".$edge."+0 -write top.miff +delete ". " -gravity northeast -crop ".$edge."x".$height."+0+".$edge." -write right.miff +delete null: "; exec("convert $cmd ");
code =>
Code: Select all
<?php
// Input image
$image = "resim.jpg";
// Resize to a png to stop quality loss
exec("convert $image -thumbnail 500x500 temp.png");
chmod ("temp.png", 0777);
// 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 = 30;
// 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} -write center.miff +delete".
" -clone 0 -crop {$width}x{$edge}+$edge+0 -write top.miff +delete ".
" -gravity northeast -crop {$edge}x{$height}+0+{$edge} -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;
chmod ("center.miff", 0777);
chmod ("right.miff", 0777);
chmod ("top_edge.miff", 0777);
chmod ("right_edge.miff", 0777);
chmod ("top.miff", 0777);
// 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 95x10+15+15 +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); }
?>