// rych { // if no thumbnail exist // create one by step downsampling using ImageMagick if ( $tn_ext == '' ) { $thdir = $dir.'thumbnail/'; @mkdir( $thdir ); $dir_unregistered_picture = $dir.$unregistered_picture; $image_size = @getimagesize( $dir_unregistered_picture ); $image_hight = $image_size[1]; $h0 = $conf['upload_maxheight_thumbnail']; $h1 = $h0 * 1.5; $h2 = $h1 * 1.5; $h3 = $h2 * 1.5; $convert = "convert $dir_unregistered_picture -quality 75"; switch ( TRUE ) { case ( $image_hight > $h3 ) : $convert .= " -unsharp 1x1+150 -resize 67%"; case ( $image_hight > $h2 ) : $convert .= " -unsharp 1x1+100 -resize 67%"; case ( $image_hight > $h1 ) : $convert .= " -unsharp 1x1+50 -resize 67%"; case ( $image_hight > $h0 ) : $convert .= " -unsharp 1x1+30 -thumbnail x$h0 $thdir$unregistered_picture"; echo $convert; passthru( $convert ); break; default: copy ($dir_unregistered_picture, $thdir.$unregistered_picture); } $tn_ext = get_extension( $unregistered_picture ); } // } rych
insert it in update.php PhpWebGallery 1.3.2, function insert_local_image(), just before
// if we found a thumnbnail corresponding to our picture... if ( $tn_ext != '' ) ...
Offline
Hello
This Mod is not working for me
It dont create any thumbnails..
and the server support image magic .
Do this mod work?
Thanks
Woody
Offline
Why don't you try it and tell us ? ^^
Offline
Nice answer!
I did try it and not for me but I thought I was doing something wrong as I'm not up to spped with php.
Thanks
Woody
Offline
Not all the servers are equiped with ImageMagick. Maybe the server you tried on has not ImageMagick installed ?
Offline
Thanks
It does so maybe it was just me.
I just wanted to make sure the code did work before I went into it more.
I'll try again.
Woody
Offline
Hi,
I modified Rych's script to use it with pwg 1.4. It needs to be inserted on line 350 of /admin/update.php, also needs the new folders and files to be set to 777 and to synchronize (update) twice.
$thdir = $dirname.'/thumbnail/'; $hidir = $dirname.'/pwg_high/'; $oldumask = umask(0); @mkdir("$thdir", 0777); @mkdir("$hidir", 0777); umask($oldumask); $filenamelow = strtolower($filename); $dirfilename = $dirname.'/'.$filename; $dirfilenamelow = $dirname.'/'.$filenamelow; rename ("$dirfilename", "$dirfilenamelow"); $hidir_filenamelow = $hidir.$filenamelow; $thdir_filenamelow = $thdir.$filenamelow; rename ("$dirfilenamelow", "$hidir_filenamelow"); $converthi = "convert $hidir_filenamelow -resize 600x600 $dirfilenamelow"; $convertth = "convert $dirfilenamelow -resize 128x128 $thdir_filenamelow"; passthru( $converthi ); passthru( $convertth );
Offline
Hi there!
If you have to update twice your original image will be lost:
you move the original image to $dirname/pwg_high/ and then resize it to 600x600 within $dirname
Synchronizing a second time would again move the (resized) image to $dirname/pwg_high/
To avoid this you have to include a "file_exist" command:
$thdir = $dirname.'/thumbnail/'; $hidir = $dirname.'/pwg_high/'; $oldumask = umask(0); @mkdir("$thdir", 0777); @mkdir("$hidir", 0777); umask($oldumask); $filenamelow = strtolower($filename); $dirfilename = $dirname.'/'.$filename; $dirfilenamelow = $dirname.'/'.$filenamelow; rename ("$dirfilename", "$dirfilenamelow"); $hidir_filenamelow = $hidir.$filenamelow; $thdir_filenamelow = $thdir.$filenamelow; if (file_exists($hidir_filenamelow)==0) { rename ("$dirfilenamelow", "$hidir_filenamelow"); $converthi = "convert $hidir_filenamelow -resize 600x600 $dirfilenamelow"; $convertth = "convert $dirfilenamelow -resize 128x128 $thdir_filenamelow"; passthru( $converthi ); passthru( $convertth ); }
Regards,
Ralf
Hi,
This code has to be placed before :
// 2 cases : the element is a picture or not, indeed .....
Files are only processed once. During the update process, PWG scans the directories (folders) to find which photos are new and which are missing their thumbnails. If you use PWG without modifications, it will list these photos. My mod uses this list to create previews (600x600) and thumbnails from the high res photos which are moved to a pwg_high folder. So they are not processed every time the update is ran.
The update has to be ran twice because the first time is used to create the other file formats, the second time is to add the previously processed photos to the database (such as in a regular update).
Best regards.
Offline
Hi torode,
hmm - I had exactly that behaviour, and after my change it worked. Anyway ...
I have another question: Where do I have to place the code if I want this script to be run automatically after uploading an image?
I don't want to cancel every time this stupid 'thumbnail upload' page and I want to see in the 'Pictures waiting' page the thumbnails - otherwise that submit page is totally senseless without seeing the thumbs.
Then there would be a good working process: users upload the pictures, they are resized to a senseful size, the original image is saved, the thumbnail is created. The Admin only has to look at 'Pictures waiting', he can directly see the thumbnail, can decide to submit it and synchronize the database (once).
So what changes do I have to do (upload.php / update.php)? I am totally lost in that PHP code, I could not even remove the call of the thumbnail upload page. It would be really cool if there could be a solution for that, and I bet most of the users would appreciate that.
Thank you very much in advance
Ralf
Hi ralf,
RalfS wrote:
I have another question: Where do I have to place the code if I want this script to be run automatically after uploading an image?
I have no idea, but the process is when you upload photos on your server -> your server has to check if it received photos (size did not change for 2 to 5 minutes) => you need to set a routine to do that (better if you own the server or if you have a root access), you must write a script that runs the update script to get the list of photos without thumbnails to create thumbnails then re-run the update script to update the database, then once more to load the IPTC datas in the database.
After having a look at the code, I found a way to create the thumbnails and previews using what was available. I had no time since then to find how I could re-run the update (maybe with an include ?), besides I thought that the process described above could use too much processor ressource.
RalfS wrote:
Then there would be a good working process: users upload the pictures, they are resized to a senseful size, the original image is saved, the thumbnail is created. The Admin only has to look at 'Pictures waiting', he can directly see the thumbnail, can decide to submit it and synchronize the database (once).
So what changes do I have to do (upload.php / update.php)? I am totally lost in that PHP code, I could not even remove the call of the thumbnail upload page. It would be really cool if there could be a solution for that, and I bet most of the users would appreciate that.
Thank you very much in advance
Ralf
I have not looked at the upload functions, because I don't allow users to do so on my own galleries, so I have no idea, but I'm sure it is possible to save the uploaded photos in a separate folder, to resize them to thumbnails and previews.
Regards.
Offline