Re: [PHP] Thumbnails in database

2004-01-17 Thread Daniel Guerrier
Why create thumnails?  You can resize the images on
the fly when needed.
--- Kevin Waterson [EMAIL PROTECTED] wrote:
 I am storing some images in a database. No problems
 there.
 But how can I create a thumbnail do store in the db
 also
 without having to create the thumbnail image on the 
 file system first?
 
 Kind regards
 Kevin
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thumbnails in database

2004-01-17 Thread Robert Cummings
 --- Kevin Waterson [EMAIL PROTECTED] wrote:
  I am storing some images in a database. No problems
  there.
  But how can I create a thumbnail do store in the db
  also
  without having to create the thumbnail image on the 
  file system first?
  
  Kind regards
  Kevin
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  

On Sat, 2004-01-17 at 10:24, Daniel Guerrier wrote:
 Why create thumnails?  You can resize the images on
 the fly when needed.

If you mean resize with img / tag then you are wasting bandwidth. If
you mean resize by creating the thumbnail at request time, then you are
wasting processing time. Unless the thumbnail is requested very
infrequently then it is usually better to have a pre-resized image, than
to resize it on the fly.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thumbnails in database

2004-01-17 Thread Mike Migurski
Why create thumnails?  You can resize the images on
the fly when needed.

It's generally good practice to trade CPU for disk space, where possible.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thumbnails in database

2004-01-17 Thread Kevin Waterson
This one time, at band camp, Daniel Guerrier [EMAIL PROTECTED] wrote:

 Why create thumnails?  You can resize the images on
 the fly when needed.

This would be too expensive.

I need to store the thumbnails in the database.
So, I need to resize the image at the same time as I store it.

I can do this and save the thumbnail in the file system, but
cannot save the thumbnail in the database.

Kind regards
Kevin

-- 
 __  
(_ \ 
 _) )            
|  /  / _  ) / _  | / ___) / _  )
| |  ( (/ / ( ( | |( (___ ( (/ / 
|_|   \) \_||_| \) \)
Kevin Waterson
Port Macquarie, Australia

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thumbnails in database

2004-01-17 Thread Peter Vertes




On Sat, 2004-01-17 at 16:44, Kevin Waterson wrote:


 Why create thumnails?  You can resize the images on
 the fly when needed.

This would be too expensive.

I need to store the thumbnails in the database.
So, I need to resize the image at the same time as I store it.

I can do this and save the thumbnail in the file system, but
cannot save the thumbnail in the database.


Kevin,

 I'm working on a web based photo gallery site which stores images in a MySQL database so you and I are working on something pretty similar. Like you I'm storing both the thumbnail (150x150) and a full sized image (768x512 or 512x768 depending on image orientation) in the database. You you could only store the full sized images in a database and resize them to thumbnails when they are needed but when you have 25 or more thumbnails to display on the same page resizing them on the fly pegs the CPU at 100% and if you have any other sites running on that same box they will experience a slow down too so that is why I opted to store the thumbnails in the database also. Disk space is very cheap and the thumbnails don't take too much space. Worse case scenario you can add another drive to the machine you are hosting the site on and presto, you have more disk space.
 In my web application I create the thumbnail and the full sized image all in one pass when a user uploads an image though a web page. Creating both the thumbnail and the full size images doesn't take that much CPU time. If I load in an image from my 2 megapixel digital camera (1600x1200) it will take 0.3 seconds on my 1.8GHz P4 to resize the image to a thumbnail and to a full sized image to be displayed in my web gallery.
 I don't know how to create an image in memory and write that to the database so I'm writing both the thumbnail and the full sized image out to my /tmp directory and then re-reading them into the database. At first I thought it might seem to be a bit inefficient but with this method I'm getting the 0.3s time to read in the original file, create a thumbnail, write it out to disk, read it into the database, create a full sized image, write it out to disk, read it into the database so I'm pretty happy with it. The code goes something like this:

---

// read in the image file from the disk that needs to be resized and uploaded
$image_original = ImageCreateFromJpeg($path_to_image_file_on_disk);

// allocate memory for the thumbnail image
$image_thumbnail = ImageCreateTrueColor($thumbnail_width, $thumbnail_height);

// copy and resize the original image into the thumbnail memory we have allocated
ImageCopyResized($image_thumbnail, $image_original, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, imagesx($image_original), imagesy($image_original));

// save the newly created thumbnail to disk
ImageJpeg($image_thumbnail, $path_to_save_thumbnail_image, 100);

// open up the thumbnail file for reading and then encode it with MIME Base64
$thumbnail_contents = base64_encode(fread(fopen($path_to_read_thumbnail_from, rb), filesize($path_to_read_thumbnail_from)));

// delete the thumbnail file from the disk
unlink($path_to_read_thumbnail_from);

// deallocate memory used to create our original and thumbnail images
ImageDestory($image_original);
ImageDestory($image_thumbnail);

---

 You do the same thing for the full sized image you want to store in the database as well but you have to make sure you get the image's orientation right otherwise your resize will give you a hard time. When it's time to insert the images into the database for the thumbnail you will insert $thumbnail_contents and whatever else variable you chose for the full sized image. One thing to watch out for is that when you read the images from the database you want to use base64_decode() on them. Hope this works out for you. If you need more help give me a shout.

-Pete




-- 
perl -e 'print pack(H*, 70766572746573406E79632E72722E636F6D0A)'








signature.asc
Description: This is a digitally signed message part


Re: [PHP] Thumbnails in database

2004-01-17 Thread Toby Irmer
http://www.sum-it.nl/en200319.php3

quote
Create thumbnail
  a.. Cropping and scaling a photo is surprisingly easy with PHP.
  b.. Unfortunately the functions imagecreatetruecolor() and
imagecopyresampled() exist only since PHP 4.0.6 using GD 2.0.1. Older PHP
version supports the functions imagecreate() and imagecopyresized(), which
are good enough to do the job.
  c.. It is possible to generate a thumbnail on the fly, in RAM memory,
using ob_start() and ob_end_clean(). That saves unnecessary fumbling around
with temporary files.
  d.. ...

/quote

hth

toby


 I am storing some images in a database. No problems there.
 But how can I create a thumbnail do store in the db also
 without having to create the thumbnail image on the
 file system first?

 Kind regards
 Kevin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thumbnails in database

2004-01-17 Thread Jason Sheets
The latest version of GD adds support for opening an image from a 
pointer to the C/C++ API but that support is not in PHP.

It is recommended to create the thumbnail on file upload using the 
$_FILES array to get the temporary file name, if you need to create a 
thumbnail from a file only in the database you need to read it, write it 
to a temporary file and then resize it, then do your action with it.

Look at tempnam() , it will generate a temporary file name for you to open.

Jason

Kevin Waterson wrote:

I am storing some images in a database. No problems there.
But how can I create a thumbnail do store in the db also
without having to create the thumbnail image on the 
file system first?

Kind regards
Kevin
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Thumbnails in database - SOLUTION

2004-01-17 Thread Kevin Waterson
This one time, at band camp, Kevin Waterson [EMAIL PROTECTED] wrote:

 I need to store the thumbnails in the database.
 So, I need to resize the image at the same time as I store it.

Ok, so the secret here is output buffering

 // prepare the image for insertion
 $imgData =addslashes (file_get_contents($_FILES['userfile']['tmp_name']));
 // do not use addslashes yet
$thumbData = $_FILES['userfile']['tmp_name'];
// get the image info..
$size = getimagesize($_FILES['userfile']['tmp_name']);
// database connection
mysql_connect(localhost, $dbusername, $dbpassword) OR DIE 
(mysql_error());
// select the db
mysql_select_db ($dbname) OR DIE (Unable to select db.mysql_error());

// create the thumbnail
$height   = '50'; // the height of the thumbnail
$width= '50'; // the width of the thumbnail
// snarf the thumbdata
$src = ImageCreateFromjpeg($thumbData);
// create the thumbnail
$destImage = ImageCreateTrueColor($height, $width);
// copy the resize/resampled image to the destImage
ImageCopyResampled($destImage, $src, 0,0,0,0, $width, $height, $size[0], 
$size[1]);
// start the output buffering
ob_start();
// pretend to send the image to the browser
imageJPEG($destImage);
// stick the output buffer in a variable
$photo_thumb = ob_get_contents();
// now we can addslashes for inserting into the db
$photo_thumb = addslashes($photo_thumb);
// tidy up a little
ob_end_clean();

   $sql = INSERT INTO phototable ( photo_id, photo_cat, photo_type ,photo_thumb, 
photo_data, photo_size, photo_name) VALUES ('', 'cat', '{$size['mime']}', 
'{$photo_thumb}', '{$imgData}', '{$size[3]}', '{$_FILES['userfile']['name']}');
   
  
// insert the image
   mysql_query($sql)

Easy as that! You do not need to create the file on the filesystem as some have 
suggested,
or use ImageCreateFromString() and pull the original out of the db. It can all be done 
in
one dastardly sweep.

Thanks to all
Kevin

-- 
 __  
(_ \ 
 _) )            
|  /  / _  ) / _  | / ___) / _  )
| |  ( (/ / ( ( | |( (___ ( (/ / 
|_|   \) \_||_| \) \)
Kevin Waterson
Port Macquarie, Australia

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] thumbnails

2003-05-29 Thread Joe Stump
I'd definitely generate them on the fly for him. I personally use the *NIX
program convert which comes with imagemagick. It works great and is easy
to use.

General Steps:

1.) Copy big image to location
2.) Use convert to make a thumbnail and name it 't_'.$image_name
3.) Put image name in a db someplace
4.) Just prefix $image_name with 't_' to get the thumbnail

I'm sure there are ways to do this within GD, but I've found Convert to be
more flexible. I have a class you can download at:

http://www.joestump.net/files/software/convert/

--Joe

--
Joe Stump [EMAIL PROTECTED]
http://www.joestump.net
Label makers are proof God wants Sys Admins to be happy.

-Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 28, 2003 7:54 AM
To: [EMAIL PROTECTED] Php. Net
Subject: [PHP] thumbnails


Ok,

I know thumbnails have been discussed and I have looked at the archives, I
am just looking for opinions.  I am doing a small website for a used vehicle
dealer.  I need to make it as easy as possible for him to add new vehicles.
I plan to just give him a form for the information, and a place to upload a
picture.  The main page will have the thumbnails of all the vehicles and as
you click on each one, you will see the normal sized photo.

Should I:

1.  Allow him to upload one picture and then somehow generate a thumbnail
from that?
   If so, should I generate the thumbnail when the picture is uploaded and
keep the original picture and the thumbnail on the
server or
   generate the thumbnail on the fly when the page is loaded...and only
store the original picture?

2.  Should I have him generate thumbnails and upload both pictures to the
server?


Thanks,
Eddie


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] thumbnails

2003-05-29 Thread CPT John W. Holmes
 I know thumbnails have been discussed and I have looked at the archives, I
 am just looking for opinions.  I am doing a small website for a used
vehicle
 dealer.  I need to make it as easy as possible for him to add new
vehicles.
 I plan to just give him a form for the information, and a place to upload
a
 picture.  The main page will have the thumbnails of all the vehicles and
as
 you click on each one, you will see the normal sized photo.

 Should I:

 1.  Allow him to upload one picture and then somehow generate a thumbnail
 from that?

Yes.

If so, should I generate the thumbnail when the picture is uploaded and
 keep the original picture and the thumbnail on the
 server or

Yes.

generate the thumbnail on the fly when the page is loaded...and only
 store the original picture?

No. No need to make the server work that much.

 2.  Should I have him generate thumbnails and upload both pictures to the
 server?

No. No need to make the user work that much. Although, if you have a
competent user who understands how to make pictures for the web, you could
actually use method two and save yourself a lot of work messing around with
image functions... The ideal system would offer the ability to do both.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] thumbnails

2003-05-29 Thread bbonkosk
Hello,

I did a family photo gallery, and from my experiences it would be best if you 
handle the thumbnail generation during the upload process.  Just make sure you 
have a naming convention or link the thumnail into your repository/DB so you 
don't loose that space when you delete the record.  It really does not consume 
too much space, pretty easy to do, and a lot easier to manage if you do it in 
your control environment.
-Brad

 Ok,
 
 I know thumbnails have been discussed and I have looked at the archives, I
 am just looking for opinions.  I am doing a small website for a used vehicle
 dealer.  I need to make it as easy as possible for him to add new vehicles.
 I plan to just give him a form for the information, and a place to upload a
 picture.  The main page will have the thumbnails of all the vehicles and as
 you click on each one, you will see the normal sized photo.
 
 Should I:
 
 1.  Allow him to upload one picture and then somehow generate a thumbnail
 from that?
If so, should I generate the thumbnail when the picture is uploaded and
 keep the original picture and the thumbnail on the
 server or
generate the thumbnail on the fly when the page is loaded...and only
 store the original picture?
 
 2.  Should I have him generate thumbnails and upload both pictures to the
 server?
 
 
 Thanks,
 Eddie
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] thumbnails

2003-05-29 Thread Edward Peloke

thanks for all the info, I am doing this project this week (hopefully) so I
am sure I will have more questions!

Eddie
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 28, 2003 7:14 AM
To: Edward Peloke; [EMAIL PROTECTED] Php. Net
Subject: Re: [PHP] thumbnails


Hello,

I did a family photo gallery, and from my experiences it would be best if
you
handle the thumbnail generation during the upload process.  Just make sure
you
have a naming convention or link the thumnail into your repository/DB so you
don't loose that space when you delete the record.  It really does not
consume
too much space, pretty easy to do, and a lot easier to manage if you do it
in
your control environment.
-Brad

 Ok,

 I know thumbnails have been discussed and I have looked at the archives, I
 am just looking for opinions.  I am doing a small website for a used
vehicle
 dealer.  I need to make it as easy as possible for him to add new
vehicles.
 I plan to just give him a form for the information, and a place to upload
a
 picture.  The main page will have the thumbnails of all the vehicles and
as
 you click on each one, you will see the normal sized photo.

 Should I:

 1.  Allow him to upload one picture and then somehow generate a thumbnail
 from that?
If so, should I generate the thumbnail when the picture is uploaded and
 keep the original picture and the thumbnail on the
 server or
generate the thumbnail on the fly when the page is loaded...and only
 store the original picture?

 2.  Should I have him generate thumbnails and upload both pictures to the
 server?


 Thanks,
 Eddie


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] thumbnails

2003-05-29 Thread Dallas Goldswain
Hi ,

I have mailed you some code i use to make thumbnails etc.
It only manipulates the image once, then stores a thumb and streams it to
the page when requested

Regards
Dallas Goldswain
Technical Director
Web|Genetics / www.development.co.za

Regards
[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello,

 I did a family photo gallery, and from my experiences it would be best if
you
 handle the thumbnail generation during the upload process.  Just make sure
you
 have a naming convention or link the thumnail into your repository/DB so
you
 don't loose that space when you delete the record.  It really does not
consume
 too much space, pretty easy to do, and a lot easier to manage if you do it
in
 your control environment.
 -Brad

  Ok,
 
  I know thumbnails have been discussed and I have looked at the archives,
I
  am just looking for opinions.  I am doing a small website for a used
vehicle
  dealer.  I need to make it as easy as possible for him to add new
vehicles.
  I plan to just give him a form for the information, and a place to
upload a
  picture.  The main page will have the thumbnails of all the vehicles and
as
  you click on each one, you will see the normal sized photo.
 
  Should I:
 
  1.  Allow him to upload one picture and then somehow generate a
thumbnail
  from that?
 If so, should I generate the thumbnail when the picture is uploaded
and
  keep the original picture and the thumbnail on the
  server or
 generate the thumbnail on the fly when the page is loaded...and only
  store the original picture?
 
  2.  Should I have him generate thumbnails and upload both pictures to
the
  server?
 
 
  Thanks,
  Eddie
 
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Thumbnails

2002-06-10 Thread John Holmes

Why reinvent the wheel?

http://gallery.jacko.com/modules.php?op=modloadname=Newsfile=index

or...

http://gallery.sourceforge.net

---John Holmes...

 -Original Message-
 From: Mantas Kriauciunas [mailto:[EMAIL PROTECTED]]
 Sent: Monday, June 10, 2002 9:48 PM
 To: PHP General List
 Subject: [PHP] Thumbnails
 
 Hey PHP General List,
 
   i am doin thing that uploads picture on the server(windows in my
   comp.) and if anybody can point me how to do fast thumbnails and
   when clicking on them it shows full size picture. I want to do it
   with one file. not cuting new one.
 
   And one more question. Can anybody point me to good tutorials about
   uploading files(it wont be more then 500kb) how it is done and all
   about that. I heared there were some bad bugs with uploading.
   Thanks for help to everyone.
 
 :--:
 Have A Nice Day!
  Mantas Kriauciunas A.k.A mNTKz
 
 Contacts:
 [EMAIL PROTECTED]
 Http://mntkz-hata.visiems.lt
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Thumbnails from Binary DB info.

2002-04-29 Thread Jason Wong

On Tuesday 30 April 2002 09:49, Shane wrote:
 Greetings folks. I'm looking for a solution to make thumbnails from my
 binary files inside my mySQL DB.

 Can anyone give me some direction for options besides Image Magick?

Manual  Image functions

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
The San Diego Freeway.  Official Parking Lot of the 1984 Olympics!
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Thumbnails and PHP

2001-01-30 Thread Brian Clark


Hello Todd, 

(TC == "Todd Cary") [EMAIL PROTECTED] uttered:

TC If I do table width="100%" and td width="750" all works fine -
TC the img's "word wrap". But, when I do table width="100%" and
TC td width="100%", I get a horizontal scroll bar and the img's
TC go off to the left.

Just leave out the width attribute for the td tag. You probably
don't want to use fixed width cells within a 100% width table.

Of course, if your images are 750 pixels wide and you put three of
them in a table cell, they're going to cause the page to scroll
horizontally no matter what you do to try to prevent it.

Might I suggest you check out some of the lists at http://www.hwg.org/
and check out the different HTML specifications at http://www.w3c.org/

It's a little daunting at first, but it's worth it to understand what
it all means.

HTH,

-Brian



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Thumbnails and PHP

2001-01-27 Thread Brian Clark


Hello Todd, 

(TC == "Todd Cary") [EMAIL PROTECTED] coined:

TC What is the best way to display thumbnail photos and their titles
TC with HTML/PHP? Table?

Sure.. tables are good. Or you can display them in one long vertical
line.. or..

Explain what you mean. If you mean just what the sentence above says,
well, it's just a matter of preference. Do what you think is best.

TC Todd

-Brian



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Thumbnails and PHP

2001-01-27 Thread Markus Fischer

On Sat, Jan 27, 2001 at 02:14:21PM -0800, Todd Cary wrote : 
 What is the best way to display thumbnail photos and their titles with
 HTML/PHP?  Table?

The html way would be to just include the photos with a small
WIDTH and HEIGHT attribute.

The php would be to read the file and use ImageCopyResized on it.

The most performant way would be to pre-generate the thumbmails
and just include them as normal images in html.

m.

-- 
Markus Fischer,  http://josefine.ben.tuwien.ac.at/~mfischer/
EMail: [EMAIL PROTECTED]
PGP Public  Key: http://josefine.ben.tuwien.ac.at/~mfischer/C2272BD0.asc
PGP Fingerprint: D3B0 DD4F E12B F911 3CE1  C2B5 D674 B445 C227 2BD0

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]