Jump to content
bubbles

Merge img

Recommended Posts

Posted

Am urmatoarele bucati de imagini :


<div id="img_final">
<img src="1.jpg"><img src="2.jpg"><img src="3.jpg"> <br/>
<img src="4.jpg"><img src="5.jpg"><img src="6.jpg"> <br/>
<img src="7.jpg"><img src="8.jpg"><img src="9.jpg"> <br/>
</div>

Care impreuna asezate ca sus formeaza o poza mare, poza de care am nevoie.

Cum as putea salva automat pozele doar intr-o singura poza ?

Ma intereseaza in PHP.

Posted

imagealphablending($image, true);
for ($i = 0; $i < count($layers); $i++) {
imagecopymerge($image, $layers[$i], 0, 0, 0, 0, $width, $height, 100);
}
imagealphablending($image, false);
imagesavealpha($image, true);

Posted (edited)

<!DOCTYPE html>
<html>
<head>
<title>Merge Image</title>
<script src="merge.js"></script>
</head>
<body>
<div id="img_final">
<img src="1.jpg"><img src="2.jpg"><img src="3.jpg"> <br/>
<img src="4.jpg"><img src="5.jpg"><img src="6.jpg"> <br/>
<img src="7.jpg"><img src="8.jpg"><img src="9.jpg"> <br/>
</div>
</body>
</html>

document.addEventListener("readystatechange", function(e) {

if (document.readyState == "complete") {

var imgs = document.getElementById("img_final");

var w = 0, h = 0;

var a = 0, b = 0;

for (var i = 0; i < imgs.childNodes.length; i++)

if (imgs.childNodes.tagName == "IMG") {

if (w < imgs.childNodes.width)

w = imgs.childNodes.width;

if (h < imgs.childNodes.height)

h = imgs.childNodes.height;

a++;

}

else if (imgs.childNodes.tagName == "BR")

b++;

var canvas = document.createElement("canvas");

canvas.width = w * a / b;

canvas.height = h * b;

var x = 0, y = 0;

var ctx = canvas.getContext("2d");

for (var i = 0; i < imgs.childNodes.length; i++)

if (imgs.childNodes.tagName == "IMG") {

ctx.drawImage(imgs.childNodes, x, y);

x += w;

}

else if (imgs.childNodes.tagName == "BR") {

y += h;

x = 0;

}

var uri = encodeURIComponent(canvas.toDataURL("image/jpg"));

//alert(uri);

}

});

L-am f?cut in javascript.. po?i trimite URI prin ajax (post) ?i s?-l salvezi într-o baz? de date.

Baft?!

Edited by H3xoR

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...