First congratulation! this software really works...the only wrong thing being perhaps the name!
I like to make a page with a strip of say 5-6 images at smallest cam size taken every 30 min + the stream video in the center at largest cam size.
This is for my sailing club to show how the weather is now and the last couple of hours. Is it possible to introduce a "picture size setting" also and separated in file-setting?
PictureSize
-
- Posts: 64
- Joined: Sat Dec 27, 2008 7:01 pm
Re: PictureSize
You are looking for a template that's will display the 5~6 latest images form your cam + Stream or you already have this template and just want a way to scale down images?alberto wrote:...make a page with a strip of say 5-6 images at smallest cam size taken every 30 min + the stream video in the center at largest cam size... ... a "picture size setting" ...
-
- Posts: 64
- Joined: Sat Dec 27, 2008 7:01 pm
The code below will:
- Resize images;
- Add date and time;
- Display latest 6 images;
- Delete original images to save disc space;
Code sources:
http://www.php.net/manual/en/function.i ... esized.php
http://stackoverflow.com/questions/3847 ... -directory
http://dont-remember-where.com/php-delete-files-codeLOL
You need a folder named "files" to upload your images and a folder named "images" to store resized images.
- Resize images;
- Add date and time;
- Display latest 6 images;
- Delete original images to save disc space;
Code sources:
http://www.php.net/manual/en/function.i ... esized.php
http://stackoverflow.com/questions/3847 ... -directory
http://dont-remember-where.com/php-delete-files-codeLOL
You need a folder named "files" to upload your images and a folder named "images" to store resized images.
Code: Select all
<?php
//resize images========================
//use this line if you get the error message of using too much memory (strip '//')
//ini_set ( "memory_limit", "48M");
$target_width = 150;
$target_height = 150;
if (ob_get_level() == 0) ob_start();
if ($handle = opendir('files/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$final_path = './images/' . basename($file);
$destination_path = './files/';
$target_path = $destination_path . basename($file);
$extension = pathinfo($target_path);
$allowed_ext = "jpg, gif, png, bmp, jpeg, JPG";
$extension = $extension[extension];
$allowed_paths = explode(", ", $allowed_ext);
$ok = 0;
for($i = 0; $i < count($allowed_paths); $i++) {
if ($allowed_paths[$i] == "$extension") {
$ok = "1";
}
}
if ($ok == "1") {
if($extension == "jpg" || $extension == "jpeg" || $extension == "JPG"){
$tmp_image=imagecreatefromjpeg($target_path);
}
if($extension == "png") {
$tmp_image=imagecreatefrompng($target_path);
}
if($extension == "gif") {
$tmp_image=imagecreatefromgif($target_path);
}
$width = imagesx($tmp_image);
$height = imagesy($tmp_image);
//calculate the image ratio
$imgratio = ($width / $height);
if ($imgratio>1) {
$new_width = $target_width;
$new_height = ($target_width / $imgratio);
} else {
$new_height = $target_height;
$new_width = ($target_height * $imgratio);
}
$new_image = imagecreatetruecolor($new_width,$new_height);
ImageCopyResized($new_image, $tmp_image,0,0,0,0, $new_width, $new_height, $width, $height);
//Grab new image
imagejpeg($new_image, $final_path);
$image_buffer = ob_get_contents();
ImageDestroy($new_image);
ImageDestroy($tmp_image);
echo str_pad('',4096)."\n";
ob_flush();
flush();
}
}
}
closedir($handle);
ob_end_flush();
}
//display latest images====================
$images = glob('images/*.{gif,png,jpg,jpeg}', GLOB_BRACE); //formats to look for
$num_of_files = 6; //number of images to display
foreach($images as $image)
{
$num_of_files--;
if($num_of_files > -1) //this made me laugh when I wrote it
echo "<br>".date('D, d M y H:i:s', filemtime($image)) ."<br><img src="."'".$image."'"."><br><br>" ; //display images
else
break;
}
//deleting the old files=========================
$files = glob('files/*'); // get all file names
foreach($files as $file){ // iterate files
if(is_file($file))
unlink($file); // delete file
}
?>
Re: PictureSize
Thankyou. That was interesting, and I learnt some.
I need a little more than that, however. I shall continue to search and work on it.
I need a little more than that, however. I shall continue to search and work on it.