General Community > WebsiteBaker Website Showcase
Some of my sites
Ruud:
It was a long time ago, but I think this was all...
In the file save_pic.php add the following code just before the line (77) that says:
--- Code: ---//guardar el file en la base de datos
--- End code ---
Code to add:
--- Code: ---//Resizer
// Check if the original image is greater than the max_size
if (is_file($nuevo_sitio)) {
$image_info = getimagesize($nuevo_sitio);
}
$max_width = 640;
//If the image is wider than the max size resize it
if ($image_info[0] > $max_width && $max_width > 0) {
echo ( 'Resizing');
// Instantiate the GD class.
$new_image = new GD;
// Set parent image path and thumbnail path.
$new_image->setFile($nuevo_sitio);
$new_image->setNewFile($nuevo_sitio);
// Resize image.
$new_image->getImageInfo();
$new_image->calcSize_thumb($max_width);
$new_image->createImage();
}
// End Resizer
--- End code ---
Good luck.
Ruud
Stefek:
It looks interesting, but I can't really follow you.
Which module do you use it in... and (more important) can this snippet be also used for another modules where I have the need to upload images (so they would be resized)?
And what happens with the original ones (5+ MegaPix)?
Best Regrards,
Stefek
Ruud:
Yes, you could use this (it might need a bit of modification for filename variables) anywhere.
I used it in the Catalogs module so my customer could upload pictures from his camera directly to the module.
The images were fixed on 640px width. (example)
This simple method will overwrite the original image, so that one is lost.
The line: $new_image->setNewFile($nuevo_sitio); sets the output file. So a new filename would create a resized copy.
The size of the image you can upload and resize depends a bit on your host. It takes pretty much memory and time to resize large images. My dev server had problems with really big (8mpx) images, where my host server didn't have problems.
Ruud
Stefek:
Thank you Ruud.
I'll get back to this trick once I need it.
Very helpful modification.
Regards,
Stefek
nibz:
Many thanks!, It realy takes time to uplode the images, but it's a good addition to the module
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version