Ver Mensaje Individual
  #6 (permalink)  
Antiguo 31/07/2011, 12:14
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: Crear imagen desde imagen

Podés usar el método toDataURL. Un ejemplo básico aquí:
Código PHP:
<!DOCTYPE html>
<
html>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Documento sin título</title>
<
script type="text/javascript">
function 
porcion(imagesxsysWidthsHeightdxdydWidthdHeight){
    if(
document.createElement('canvas').getContext){
        var 
c=document.createElement('canvas');
        
c.width=dWidth;
        
c.height=dHeight;
        
ctx=c.getContext('2d');
        
ctx.drawImage(imagesxsysWidthsHeightdxdydWidthdHeight);
        var 
src=c.toDataURL();
        var 
im=document.createElement('img');
        
im.src=src;
        
document.body.appendChild(im);
        
im=c=null;
    }
}
</script>

</head>

<body>
<img id="pp" src="arwen.jpg" width="500" height="350" />
<form>
    <input onclick="porcion(document.getElementById('pp'), 0, 0, 50, 50, 0, 0, 50, 50)" type="button" name="button" id="button" value="porcion1" />
    <input onclick="porcion(document.getElementById('pp'),50, 100, 100, 100, 0, 0, 100, 100)" type="button" name="button2" id="button2" value="porcion2" />
</form>
</body>
</html>