JavaScript Image Rotator

Tuesday, March 9, 2010 2:40
Posted in category JavaScript

We can rotate the image by angle.here is a source code for it ..( rotate an image by an arbitrary angle, it works in IE7 & FF3

<script type=”text/javascript”>
<!–
//******************** Image parameters *******************
imagename=’example.jpg’
xsize=200
ysize=100
//*********** nothing to configure below this line ********
//–>
</script>

</head>
<body style=”margin:20px”>
<H1>Universal JavaScript Image Rotator v1.0 (14-03-2009)</H1>
<div id=”container” style=”overflow:hidden”>
<script type=”text/javascript”>
<!–
canvsize=Math.round(Math.sqrt(xsize*xsize+ysize*ysize)); //I need a square canvas for complete rotation
document.write(’<canvas id=canvas width=’+canvsize+’ height=’+canvsize+’></canvas>’)
document.write(’<div id=”canvas2″><img id=im width=’+xsize+’ height=’+ysize+’></div>’)
//–>
</script>

<script type=”text/javascript”>
<!–
ie=0
var browser=navigator.appName;
if (browser==’Microsoft Internet Explorer’) ie=1;

document.getElementById(”container”).style.width=canvsize+’px’
document.getElementById(”container”).style.height=canvsize+’px’
//document.getElementById(”canvas”).style.width=canvsize+’px’
//document.getElementById(”canvas”).style.height=canvsize+’px’
document.getElementById(”canvas2″).style.width=xsize+’px’
document.getElementById(”canvas2″).style.height=ysize+’px’
document.getElementById(”canvas2″).style.marginLeft=(canvsize-xsize)/2+’px’
document.getElementById(”canvas2″).style.marginTop=(canvsize-ysize)/2+’px’

var browser=navigator.appName;
if (ie==1) {
document.getElementById(’im’).src=imagename;
var canvas2=document.getElementById(’canvas2′);
canvas2.style.filter=”progid:DXImageTransform.Microsoft.Matrix(M11=’1.0′, sizingmethod=’auto expand’)”;
}
else {
var canvas = document.getElementById(’canvas’);
var ctx = canvas.getContext(’2d’);
var img1 = new Image();
img1.src = imagename;
img1.onload=function() { ctx.drawImage(img1, (canvsize-xsize)/2, (canvsize-ysize)/2, xsize, ysize);}
}

function rotate(deg){
rad = deg*Math.PI/180
if (ie==1) rotate_ie(rad,deg)
else rotate_ff(rad)
}

function rotate_ff(rad) {
ctx.clearRect(0,0,canvsize,canvsize);
ctx.save();
ctx.translate(canvsize/2,canvsize/2);
ctx.rotate(rad);
ctx.drawImage(img1, -xsize/2, -ysize/2, xsize, ysize);
ctx.restore();
}

function rotate_ie(rad)
{
canvas2.filters.item(0).M11 = Math.cos(rad);
canvas2.filters.item(0).M12 = -Math.sin(rad);
canvas2.filters.item(0).M21 = Math.sin(rad);
canvas2.filters.item(0).M22 = Math.cos(rad);
canvas2.style.marginLeft=((canvsize-canvas2.offsetWidth)/2)+’px’
canvas2.style.marginTop=((canvsize-canvas2.offsetHeight)/2)+’px’
}
//–>
</script>
</div>

<p>
Enter the number of degrees (positive or negative) you want to rotate the image:<BR>
<input type=”text” id=”rotation”>
<input type=”button” value=”Rotate” onclick=”rotate(document.getElementById(’rotation’).value);”>
</p>

How to Redirect from Your Root Domain to the WWW Subdomain

Wednesday, February 17, 2010 2:14
Posted in category PHP

How to Redirect from Your Root Domain to the WWW Subdomain and Vice Versa Using mod_rewrite?

Most websites stick to one form of their domain name when they refer to their own site, be it the plain domain name, like example.com, or the www form, like www.example.com. Unfortunately others linking to you don’t always follow your preferred style. If some sites link to you with just the domain name, and others link using the www subdomain, then your site may face issues with the search engines. This article shows you how you can work around the problem by automatically redirecting all URL requests of one form to the other in a search engine friendly way.

Read the rest of this entry »

404 redirect using htaccess

Wednesday, February 17, 2010 2:05
Posted in category PHP

How do I make it so instead of a 404, the home page or any specified page comes up?

Here is simple trick for that ..

You will probably want to create an error document for codes 404 and 500, at the least 404 since this would give you a chance to handle requests for pages not found. 500 would help you out with internal server errors in any scripts you have running. You may also want to consider ErrorDocuments for 401 – Authorization Required (as in when somebody tries to enter a protected area of your site without the proper credentials), 403 – Forbidden (as in when a file with permissions not allowing it to be accessed by the user is requested) and 400 – Bad Request, which is one of those generic kind of errors that people get to by doing some weird stuff with your URL or scripts.

Read the rest of this entry »

Welcome to Altmint Blog

Friday, February 5, 2010 9:47
Posted in category Altmint

Altmint is a premier PHP Web Development Company located in Hyderabad (India). We have experienced PHP professionals who can help clients from India, USA, UK, Canada, AUS and other European countries in the field of website development, software development, website maintenance and much more.

Altmint has a large pool of resources and the required business and technical expertise to develop websites of any complexity. We provide complete front-end and back-end development based on the latest technologies and industry trends . we can create fast, scalable and secure custom database driven web sites and applications..

Our experienced PHP programmers are dedicated to LAMP (Linux operating system; Apache Web server; My SQL database management system or database server; PHP, Python scripting/programming languages).

This blog will run through our experienced PHP programmers. They will write about their real time Experiences in web programming that are very useful for all the developers.