12 September 2010

Edit ukuran gambar

script di bawah ini untuk me edit gambar menjadi ukuran yg lebih besar , lebih kecil
ok langsung aja yaa copas source code di bawah ini lalu save dengan extention .HTML

source code'a :

<html>
<head>
<title>Ubah Size Image</title>

<script type="text/javascript">

var panjang;
var lebar;
var n = 0;

function bacaUkuran()
{
panjang = document.getElementById("gambar").width;
lebar = document.getElementById("gambar").height;
}

function tambahSize()
{
n++;
document.getElementById("gambar").width = Math.pow(2, n) * panjang;
document.getElementById("gambar").height = Math.pow(2, n) * lebar;
}

function kurangiSize()
{
n--;
document.getElementById("gambar").width = Math.pow(2, n) * panjang;
document.getElementById("gambar").height = Math.pow(2, n) * lebar;
}

function resetSize()
{
n = 0;
document.getElementById("gambar").width = Math.pow(2, n) * panjang;
document.getElementById("gambar").height = Math.pow(2, n) * lebar;
}

</script>
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-size: 36px;
}
-->
</style>
</head>
<body onLoad="bacaUkuran()">
<div align="center">
<h1 class="style1">Edit Image </h1>
<h2>Indonesianhacker</h2>
<input type="button" value="-" onClick="kurangiSize()" />
<input type="button" value="=" onClick="resetSize()" />
<input type="button" value="+" onClick="tambahSize()" /><br /><br />
<img id="gambar" src="IHT.jpeg" />
</div>
</body>
</html>

semoga bermanfaat ..

Tidak ada komentar: