Progged programming site

Programming source code, articles, tutorials, links and chat

Find freelance programmers at ScriptLance.com - Search worldwide

A PHP Image Resize Function

This PHP function has 3 parameters the first allows you to input your image ,the second is  the percentage you wish the width to be displayed at and lastly the third is the percentage you wish the height to be displayed at

imageresize.php code

<?php
function ResizeImage($image ,$width ,$height)
{
//image resizer by myscripting
//get the size of the original
$size = GetImageSize($image);
//divide the width / height percentage by 100
$new_width = 100 / $width;
$new_height = 100 / $height;
//store the resized dimensions in a variable
$sizeh = $size[1]/ $new_height;
$sizew= $size[0]/ $new_width;
//display the new resized image
$new_image = ""<img src = \""$image\"" height=\""$sizeh\"" width =\""$sizew\"">"";
echo $new_image;
}
?>

Here is how we call this script with some examples .

<?php
require(""imageresize.php"");
//this reduces the image
ResizeImage(""1.gif"",50,50);
echo ""<br>"";
//we can increase an image as well
ResizeImage(""1.gif"",150,150);
?>

Add an entry to the application log

This VBScript example will add an entry to the application log

Const EVENT_SUCCESS = 0

Set objShell = Wscript.CreateObject(”Wscript.Shell”)

objShell.LogEvent EVENT_SUCCESS,”This is a test Application event log entry.

Get the Windows XP serial number

This example shows how to list the serial number for your installed copy of Windows XP, you need to add a textbox caled TextBox1 to a form in this example

Sub WindowsSerial()

strComputer = “.”
Set objWMIService = GetObject(”winmgmts:\\” & strComputer & “\root\cimv2″)
Set colItems = objWMIService.ExecQuery(”Select * from Win32_OperatingSystem”, , 48)
For Each objItem In colItems
Text1.Text = objItem.SerialNumber
Next
End Sub

Private Sub Form_Load()
WindowsSerial
End Sub

create a MySQL database using PHP

This code snippet example shows how to  create a MySQL database using PHP

<?php

$result = mysql_create_db(”mydb”);
if ($result == false)
echo (”failure to create database”);

?>

Sponsors