Welcome, Guest. Please login or register.
Login with username, password and session length


It's a release candidate! VirtueMart 2.0 RC - the next generation VirtueMart - is available! Read more....

  Advanced search

247038 Posts in 67506 Topics- by 258314 Members - Latest Member: aniketana
Pages: [1]   Go Down
Print
Author Topic: resize full product image  (Read 13091 times)
scats
Newbie
*
Posts: 1


« on: February 05, 2008, 06:54:06 AM »

Hi,
I'm looking for a possibility to resize dynamicly the full product image (not the thumb) and give it maximal dimensions during uploading. Not resize the image afterwards in the shop_product_details.php or the flypage.php. I searched the forum but didn't find anything.
Logged
jenkinhill
Global Moderator
Hero Member
*
Posts: 9763



WWW
« Reply #1 on: February 05, 2008, 08:25:00 AM »

The image should be at the required full size before uploading. You could use a batch resizer before uploading?
Logged

Kelvyn
Jenkin Hill Internet,
Keswick, Lake District

Please do not PM or Email me with support questions. I look at PMs only once a month. You will get better and faster responses in the support forums.

Current recommended release versions are: Joomla! 1.5.23 :: VirtueMart 1.1.8

URGENT:  Help VirtueMart development by testing  version 1.1.9
RolandD
Hero Member
*****
Posts: 756


WWW
« Reply #2 on: February 05, 2008, 11:26:36 AM »

scats,

The upcoming beta 5 of CSV Improved gives you the option to set the width and height of your thumbnails during import. This means, you could do a simple upload of product_sku, product_full_image and product_thumb_image and set the size of the thumb in the template. This would resize all your images on the fly.

If you care to test please contact me via PM.
Logged

Regards,

RolandD

CSVI VirtueMart
CSVI JoomFish
VM Download Manager
VmCategoryModule
VmCategoryBot:
http://www.csvimproved.com/
Andrew
Full Member
***
Posts: 110



WWW
« Reply #3 on: September 03, 2008, 05:27:33 AM »

Is there any update to this? Clients don't know how to batch resize files and will end up sticking huge files up. I'm sure the old version could do it.

Andrew
Logged
ayeaye
Newbie
*
Posts: 1


« Reply #4 on: December 10, 2008, 05:15:26 AM »

I did this in a hurry (main product image resize to max height/width 600px) by hacking the administrator/components/com_virtuemart/classes/imageTools.class.php file:

Change:

Code:
// Resize the Full Image
if( !empty ( $_FILES[$tmp_field_name]["tmp_name"] )) {
$full_file = $_FILES[$tmp_field_name]["tmp_name"];
$image_info = getimagesize($full_file);

}

To:

Code:
// Resize the Full Image
if( !empty ( $_FILES[$tmp_field_name]["tmp_name"] )) {
$full_file = $_FILES[$tmp_field_name]["tmp_name"];
$image_info = getimagesize($full_file);
$original_height =  $image_info[1];
$original_width =  $image_info[0];
if ($original_height > $original_width) {
$largewidth = (600 / $original_height) * $original_width;
$largeheight = "600px"; } else {
$largeheight = (600 / $original_width) * $original_height;
$largewidth = "600px"; }


$largeimage = imagecreatefromjpeg($full_file);
$big = imagecreatetruecolor($largewidth, $largeheight);
imagecopyresampled($big, $largeimage, 0, 0, 0, 0,
$largewidth, $largeheight, $original_width, $original_height);
imagejpeg($big, $full_file);
imagedestroy($largeimage);
imagedestroy($big);

}

Seems to work! Main product image re-size definitely needed in next version! :-)
Logged
rj8
Newbie
*
Posts: 4


« Reply #5 on: June 18, 2009, 06:16:29 AM »

I can't believe that nobody has replied to this solution!!??
This was most likely ment for VM1.0.x but also works on VM1.1.x!!

At least...it works for me...no problems encoutered yet. Please test if it will work for you also!

Ronald
Logged
demarque
Newbie
*
Posts: 11


« Reply #6 on: August 10, 2009, 22:45:16 PM »

unfortunetly i change the code but nothing change

do i have to reupload a image for take effect ?

im gonna try anyway
Logged
thewizster
Newbie
*
Posts: 6


« Reply #7 on: September 04, 2009, 12:29:39 PM »

rj8 I'm with you on this. Can't believe it. The solution posted by ayeaye worked for me too. I'm running vm 1.1.3

This should be built in. The end user problem is this. Cameras today take HUGE resolution images. It's a pain to expect someone to resize all their images before uploading them to VM. VM already resizes thumbnails why not the full product image as well?

I can't see a need to upload 2048 x 1536 images from my camera. That high of quality is not needed on a website imho...
Logged
TerraGuy
Newbie
*
Posts: 4


« Reply #8 on: September 11, 2009, 20:58:46 PM »

This works great, only not for PNG or GIF-files.
Logged
TerraGuy
Newbie
*
Posts: 4


« Reply #9 on: September 11, 2009, 21:29:49 PM »

I tried some things, and I figured out a way to get it to use PNG and GIF too. This is based on the code from ayeaye, and should be copied on the same place.

Although it works for me, I'm not a real programmer, so there might be some errors or unnecessary code. If a more experience programmer would have a look at it, that would be great! Smiley

Code:
// Resize the Full Image
if( !empty ( $_FILES[$tmp_field_name]["tmp_name"] )) {
$full_file = $_FILES[$tmp_field_name]["tmp_name"];

$image_info = getimagesize($full_file);
$original_height =  $image_info[1];
$original_width =  $image_info[0];

if ($original_height > $original_width) {
$largewidth = (600 / $original_height) * $original_width;
$largeheight = "600px";
} else {
$largeheight = (600 / $original_width) * $original_height;
$largewidth = "600px";
}

//Get Image size info
    list($original_width, $original_height, $image_type) = getimagesize($full_file);
   
switch ($image_type)
{
    case 1: $im = imagecreatefromgif($full_file); break;
case 2: $im = imagecreatefromjpeg($full_file);  break;
    case 3: $im = imagecreatefrompng($full_file); break;
    default:  trigger_error('Unsupported filetype!', E_USER_WARNING);  break;
}

$big = imagecreatetruecolor($largewidth, $largeheight);

/* Check if this image is PNG or GIF, then set if Transparent*/
    if(($image_type == 1) OR ($image_type==3))
    {
        imagealphablending($big, false);
        imagesavealpha($big,true);
        $transparent = imagecolorallocatealpha($big, 255, 255, 255, 127);
        imagefilledrectangle($big, 0, 0, $largewidth, $largeheight, $transparent);
    }
    imagecopyresampled($big, $im, 0, 0, 0, 0, $largewidth, $largeheight, $original_width, $original_height);
   
    //Generate the file, and rename it to $newfilename
    switch ($image_type)
    {
        case 1: imagegif($big,$full_file); break;
        case 2: imagejpeg($big,$full_file);  break;
        case 3: imagepng($big,$full_file); break;
        default:  trigger_error('Er ging iets fout!', E_USER_WARNING);  break;
    }}
Logged
shunsho
Newbie
*
Posts: 1


« Reply #10 on: September 17, 2009, 00:52:42 AM »

Hello everybody...


guys....you are great...the hack is perfect...congratulations and thank you so much!!
Logged
Therasya
Newbie
*
Posts: 29


« Reply #11 on: November 13, 2009, 12:23:13 PM »

rj8 I'm with you on this. Can't believe it. The solution posted by ayeaye worked for me too. I'm running vm 1.1.3

This should be built in. The end user problem is this. Cameras today take HUGE resolution images. It's a pain to expect someone to resize all their images before uploading them to VM. VM already resizes thumbnails why not the full product image as well?

I can't see a need to upload 2048 x 1536 images from my camera. That high of quality is not needed on a website imho...
I have the same problem, where is the solution?
Logged
Pages: [1]   Go Up
Print
Jump to: