Set Frame on Image by Append and Merge

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
pranav
Posts: 16
Joined: 2014-05-20T23:41:16-07:00
Authentication code: 6789

Set Frame on Image by Append and Merge

Post by pranav »

Hi All,
I am trying to resize the image and trying to set frame onto 4 side of the image,
My code is given here, I dont know how to do that,
If any one have idea, Please help me to solve this example
I have added the images of various sizes, 1.jpg, 2.jpg, 3.jpg, 4.jpg, 5.jpg
Need to set the frame on that.

https://www.dropbox.com/s/6exr8tvgja1c8 ... border.zip

Thanks in advance.... :)
pranav
Posts: 16
Joined: 2014-05-20T23:41:16-07:00
Authentication code: 6789

Re: Set Frame on Image by Append and Merge

Post by pranav »

Here is My latest code, Just need to put the left and right edges on the back side only, but still resizing is not working with, for image 2.jpg

<?php
// Input image
$image = '3.jpg';
// Resize to a png to stop quality loss
exec("convert $image -thumbnail 500x500 temp.png");
$size = getimagesize('temp.png');
//echo "<pre>";print_r($size);echo "</pre>";
$w = $size[0];
$h = $size[1];
if($w > $h){
$c_w = 635;
$c_h = 590;
}elseif($w == $h){
$c_w = 635;
$c_h = 590;
}else{
// $c_w = (500 * 90) / $w;
$c_w = $w + 90;
$c_h = 500;
}
exec("convert brown_golden_top.jpg -thumbnail {$c_w}x{$c_h} brown_golden_top.png");
exec("convert brown_golden_top.png -flip brown_golden_bottom.png");
exec("convert brown_golden_top.png -rotate 270 brown_golden_left.png");
exec("convert brown_golden_left.png -flop brown_golden_right.png");

$cmd = 'brown_golden_top.png -background none temp.png -background white -gravity center -append append_center.png';// Display the final image
exec("convert $cmd");
$cmd = "composite -gravity east brown_golden_right.png append_center.png append_center_1.png";
exec("$cmd");
$cmd = "composite -gravity south brown_golden_bottom.png append_center_1.png append_center_2.png";
exec("$cmd");
$cmd = "composite -gravity west brown_golden_left.png append_center_2.png append_center_3.jpg";
exec("$cmd");
echo "<img src=\"append_center_3.jpg\">";
?>
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Set Frame on Image by Append and Merge

Post by Bonzo »

Have you see this post on Anthony's website: http://www.imagemagick.org/Usage/thumbnails/#frame_edge

Try this:

Code: Select all

<?php
$cmd =" 1.jpg -write mpr:image +delete ".
" brown_golden_top.jpg -write mpr:edge_top +delete ".
" brown_golden_bottom.jpg -rotate 180 -write mpr:edge_btm +delete ".
" mpr:image -alpha set -bordercolor none ".
" -compose Dst -frame 53x53+53  -compose over ".
" -transverse  -tile mpr:edge_btm ".
" -draw \"color 1,0 floodfill\" -transpose -draw \"color 1,0 floodfill\" ".
" -transverse  -tile mpr:edge_top ".
" -draw \"color 1,0 floodfill\" -transpose -draw \"color 1,0 floodfill\" ".
" mpr:image -gravity center -composite ";
		  
exec("convert  $cmd  frame_gold.png");

?>

<img src="frame_gold.png">
pranav
Posts: 16
Joined: 2014-05-20T23:41:16-07:00
Authentication code: 6789

Re: Set Frame on Image by Append and Merge

Post by pranav »

Hey Bonzo,
You got thousands salute....... :D

You gave a single line answer, but you know , I an confused with this logic, as i am a new born fish in this ocean.

What all this syntax means, I am trying to learning meanwhile.

Thank a Lot again, You helped me.

One personal question on the closing of this issue,
What are you guy have in food everyday, man???...... I would like to have all those food, so i can learn quickly.....


Cheers.....
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Set Frame on Image by Append and Merge

Post by Bonzo »

I can not take credit as I only slightly modified Anthony's example.
pranav
Posts: 16
Joined: 2014-05-20T23:41:16-07:00
Authentication code: 6789

Re: Set Frame on Image by Append and Merge

Post by pranav »

Yeah, I would Say, Antony Sir.... :)
Post Reply