Archive

Posts Tagged ‘image’

Image Resize Simple class

September 11th, 2009 R Arun Raj No comments

Here is a sample class file for image resize.image-resize-class

imageResize.class

Download the File  save it in web root and add .php extension to the file  .

How to use ?

<?php

require_once(‘imageResize.class.php’); // Path to File

imagejpeg(imageResize::Resize($fileSavePath,$width,$height),$newFileName);

?>

$fileSavePath should be the pathname of source file. Say “uploads/arun.jpg”.

$newFileName this should be the source File name with path.  Say “uploads/thumb/arun.jpg”.

Any Doubt ?

Categories: PHP Tags: , , ,

How to validate image File field using Javascript

May 23rd, 2008 R Arun Raj No comments

<script type=”text/javascript”>
function validateFileExtension(ld) {
if(!/(\.bmp|\.gif|\.jpg|\.jpeg)$/i.test(ld.value)) {
alert(“Invalid image file type.”);
ld.form.reset();
ld.focus();
return false;
}
return true;
}
</script>

How to create thumbnails ( Logic ) in PHP

March 15th, 2008 R Arun Raj No comments

How to create thumbnails ( Logic )

Scan a folder for JPG and PNG files (gd does not support GIF anymore, because the packing algorithm in GIF is copyrighted ).
Take each of these images, and load it.
Resize the image.
Save the image as a thumbnail.
The resizing idea is the following:

We assume the thumbnail should be 100 pixels, either wide or high.
We load the original image, and check its dimensions.
If the picture is higher than wide, we set the height of the thumb to 100 pixels.
The width of the thumbnail is the original width multiplied with 100 pixels divided by its height.
Thumbnail height = original width * (100 / original height)
This way we preserve the original aspect ratio.
If the original picture is wider than high, we do the same to the height of the thumbnail.
If they are the same, we simply create a 100×100 pixels image.
Back to table of contents
The PHP functions to use
PHP has a whole lot of functions to help us with generating graphics with gd.

For The example with php try this link
http://icant.co.uk/articles/phpthumbnails/
best of luck

Categories: Misk Tags: , , ,