473,385 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Picture Gallery which rezises images

Hello!

I tested several picture galleries now but I didn't find anyone I like.

It should be very simple (just login and upload) but it should be able
to rezise pictures. You specify a value for the max height and max width
and depending if the hight or width is more the picture will be rezised
so that it fits into the gallery thumnails even if it was taken 90°
rotated.

Is there such a script available somewhere?
Jul 27 '05 #1
2 2312
I noticed that Message-ID:
<42***********************@newsreader.inode.at> from Martin Brunner
contained the following:
It should be very simple (just login and upload) but it should be able
to rezise pictures. You specify a value for the max height and max width
and depending if the hight or width is more the picture will be rezised
so that it fits into the gallery thumnails even if it was taken 90°
rotated.

Is there such a script available somewhere?


Not a gallery script, but my upload script does what you want

<?php

$path = "images/main/";
$thumbpath = "images/thumb/";
$thumbnail_width=50;
$mainpath="images/main/";
$main_width=450;
$max_size = 2000000;
$filename="";
if (!empty($_FILES['userfile'])) {

if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {

if ($_FILES['userfile']['size']>$max_size)
{ echo "The file is too big<br>\n"; exit; }

if($_FILES['userfile']['type']=="image/gif"){
$createfunction="imagecreatefromgif";}
else{$createfunction="imagecreatefromjpeg";}

if (($_FILES['userfile']['type']=="image/gif") ||
($_FILES['userfile']['type'])=="image/pjpeg" ||
($_FILES['userfile']['type']=="image/jpeg")) {

//check if file already uploaded
//if (file_exists($thumbpath ."s_".
$_FILES['userfile']['name'])) { echo "The file already exists<br>\n";
exit; }

//make a copy of original file
//$res = copy($_FILES['userfile']['tmp_name'], $path .
//$_FILES['userfile']['name']);

//create thumbnail image
$src_img = $createfunction($_FILES['userfile']['tmp_name']);
$new_w = $thumbnail_width;
$new_h = imagesy($src_img)/(imagesx($src_img)/$new_w);
$dst_img = imagecreatetruecolor($new_w,$new_h);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w,
$new_h, imagesx($src_img), imagesy($src_img));
imagejpeg($dst_img, $thumbpath
.."s_".$_FILES['userfile']['name'], 100);

//create big image
if(imagesx($src_img)>450){
$new_w = $main_width;
$new_h = imagesy($src_img)/(imagesx($src_img)/$new_w);
$dst_img = imagecreatetruecolor($new_w,$new_h);
$res=imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0,
$new_w, $new_h, imagesx($src_img), imagesy($src_img));
imagejpeg($dst_img, $path ."b_".
$_FILES['userfile']['name'], 50);
$notify = "Main image resampled";
}
else{
$res = copy($_FILES['userfile']['tmp_name'], $path
.."b_".
$_FILES['userfile']['name']);
$notify = "Main image not resampled";
}

if (!$res) { echo "<h2>Upload failed!</h2><br>\n"; exit;
}
else { echo "<h2>Upload sucessful!</h2>\n";
}

$filename=$_FILES['userfile']['name'];
printf("<strong>Main :
</strong>%sb_%s<br>\n",$path,$filename);
printf("<strong>Thumbnail :
</strong>%ss_%s<br>\n",$thumbpath, $filename);

echo "Original File Size:
".$_FILES['userfile']['size']." bytes<br>\n";
echo "File Type: ".$_FILES['userfile']['type']."<br>\n";
echo "$notify.<br>\n";
}

else { echo "<span class=\"indent10bold\">Please use a
..jpg or a .gif file</span><br>\n"; exit; }

printf("<span class=\"indent10bold\">Image Thumbnail:
</span><br><br><span class=\"indent10bold\"><img
src=\"%ss_%s\"alt=\"%s\"></span><br>",$thumbpath,$filename,$_POST['alt_text']);
imagedestroy($src_img);
imagedestroy($dst_img);
}
//end of image upload

//variables for insertion into product table
$thumb_url="s_".$filename;
$main_url="b_".$filename;

}

?>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 27 '05 #2
JDS
On Wed, 27 Jul 2005 18:42:38 +0200, Martin Brunner wrote:
I tested several picture galleries now but I didn't find anyone I like.


http://gallery.menalto.com

--
JDS | je*****@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Jul 27 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Simone Winkler | last post by:
Hello, I don't know if my question is out of topic...so I apologize if I am. I use the coppermine picture gallery for my web (actually I want to use it but the server doesn't seem to have GD...
2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
54
by: Max Quordlepleen | last post by:
Apologies for the crossposting, I wasn't sure which of these groups to ask this in. I have been lurking in these groups for a week or so, trying to glean what I need to design a simple, clean...
6
by: VB Programmer | last post by:
I am creating an online, interactive, art gallery using ASP.NET. I want the user to be able to select (1) a frame type & size, (2) a matte type & color and (3) a picture. I will then display...
13
by: Jim Carlock | last post by:
I have over a hundred pictures I would like to present. Is it practical to create and parse an array of pictures, picture paths, et al using server-side scripting to accomplish this? I...
11
by: ste | last post by:
Hi there, Further to my recent posts where I've received excellent help from Rik and Jerry, I've ended up with an image gallery on my website that displays images in a table, 3 images per row. ...
0
by: numbnutz | last post by:
Hi, I am currently working on an XML Gallery for my girlfriend's brother who is a photographer. I have created a flash front end template and am using an XML database to load the images and...
5
by: dabhand | last post by:
Hi This page http://www.dabhand.co.nz/ayupdev/gallery-riders.html works great in IE but not in Firefox... any help would be appreciated. It refers to an external javascript file which I have...
1
by: chadmathbiz | last post by:
Hello, and nice to meet all of you: My name's Chad, and I have a head-bashing problem. I built out a photo gallery with very specific mouseover/onclick etc. behaviors. It works fine in Firefox....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.