With this script you can resize your image, ad a watermark or copyright to image and output the image in JPEG, GIF or PNG format.
Usage:
1. Parameters are passed via URL: image.php?image=1.jpg;
2. You can set the type of your output image to JPG, GIF or PNG format like this: image.php?image=1.jpg&type=png; If you don't specify the type of the output image, the script will output the image in the original format image.php?image=1.jpg;
3. To add a watermark to image you heave to set 2 variables: watermark_text and watermark_color(optional).Black will be use if you do not set the watermark_color;
Example:
1) image.php?image=1.jpg&watermark_text=1234567890&watermark_color=fffff;
2) image.php?image=1.jpg&watermark_text=1234567890;
4. Resizing images:
a. Exact size:
Variables: w and h
Example: image.php?image=1.jpg&w=100&h=100
b. Maxim size:
Variable: maxim_size
Example: image.php?image=1.jpg&maxim_size=300
c. Percent:
Variable: percent
Example: image.php?image=1.jpg&percent=50
d. Square:
Variable: square
Example: image.php?image=1.jpg&square=100
I use this type of resizing for creating thumbnails that heave the same size
<?
/*
http://www.phpscriptexpert.com/script.php?pn=Image...%20and%20Watermark&pid=198
*/
if($_GET['image']){
$image = $_GET['image'];
if($_GET['type']=="jpg"){
header("Content-type: image/jpeg");
}elseif($_GET['type']=="gif"){
header("Content-type: image/gif");
}elseif($_GET['type']=="png"){
header("Content-type: image/png");
}else{
if(substr($image, -3)=="jpg" || substr($image, -3)=="JPG"){header("Content-type: image/jpeg");}
elseif(substr($image, -3)=="gif" || substr($image, -3)=="GIF"){header("Content-type: image/gif");}
elseif(substr($image, -3)=="png" || substr($image, -3)=="PNG"){header("Content-type: image/png");}
}
if(substr($image, -3)=="jpg" || substr($image, -3)=="JPG"){$im = imagecreatefromjpeg($image);}
elseif(substr($image, -3)=="gif" || substr($image, -3)=="GIF"){$im = imagecreatefromgif($image);}
elseif(substr($image, -3)=="png" || substr($image, -3)=="PNG"){$im = imagecreatefrompng($image);}
if($_GET['percent']){
$x = round((imagesx($im)*$_GET['percent'])/100);
$y = round((imagesy($im)*$_GET['percent'])/100);
$yyy=0;
$xxx=0;
$imw = imagecreatetruecolor($x,$y);
}elseif($_GET['w'] and $_GET['h']){
$x = $_GET['w'];
$y = $_GET['h'];
$yyy=0;
$xxx=0;
$imw = imagecreatetruecolor($x,$y);
Используем библиотеку opacity.js
<html> <head> <!-- Устанавливаем изначальную прозрачность картинок --> <style type="text/css"> img { filter:alpha(opacity=30); -moz-opacity: 0.3; -khtml-opacity: 0.3; opacity: 0.3; } </style> <!-- Подключаем библиотеку --> <script type="text/javascript" src="/js/opacity.js"></script>
<script type="text/javascript"> // Создаем правило изменения прозрачности: задаем имя правила, начальную и конечную прозрачность, а также необязательный параметр задержки влияющий на скорость смены прозрачности fadeOpacity.addRule('oR1', .3, 1, 30); </script> </head>
<body> <img id="fImg1" onMouseOver="fadeOpacity(this.id, 'oR1')" onmouseout="fadeOpacity.back(this.id)" src="/img/strawberry.jpg" width="100" height="80" /> <img id="fImg2" onMouseOver="fadeOpacity(this.id, 'oR1')" onmouseout="fadeOpacity.back(this.id)" src="/img/tomato.jpg" width="82" height="100" /> <img id="fImg3" onMouseOver="fadeOpacity(this.id, 'oR1')" onmouseout="fadeOpacity.back(this.id)" src="/img/sweet_cherry.jpg" width="98" height="97" /> </body> </html>