I am wondering how cached images work. I set my popup product images to 900x900 then I noticed that it adds white space to the image if it is not 900x900 rather then just resize by width only. For example if a photo is 1000x600 open cart will make it 900x900 if you set that in the admin instead of something like 900x550 if it were to resize by width only while keeping the aspect ratio. Maybe the settings page should have a "resize by" setting. Resize by width, height, both or best fit.
Now I am trying to change the size on the settings page but I guess after the images have been cached you can no longer change them. Is there any way to delete the cache and have it rebuilt other then re-uploading all the photos in the store.
Now I am trying to change the size on the settings page but I guess after the images have been cached you can no longer change them. Is there any way to delete the cache and have it rebuilt other then re-uploading all the photos in the store.
Henry Weismann
877.44.MY.WEB (877.446.9932)
We can help with your Opencart Site - Opencart Web Developer
It should already be keeping the best aspect ratio. It you upload a 300x800 image and then a 800x300 imagehcamelion wrote:I am wondering how cached images work. I set my popup product images to 900x900 then I noticed that it adds white space to the image if it is not 900x900 rather then just resize by width only. For example if a photo is 1000x600 open cart will make it 900x900 if you set that in the admin instead of something like 900x550 if it were to resize by width only while keeping the aspect ratio. Maybe the settings page should have a "resize by" setting. Resize by width, height, both or best fit.
It will pad whitespace on the sides of the first one to make it square
It will pad whitespace on the top and bottom of the second one to make it square.
The idea here is to make all images look the same on the store front so they aren't all different sizes making your page all janky.
Its just using the normal php resizing features used in "imagecreatefromjpg" built in function. So it's a standard function.
As Daniel said, if the image is newer it will regenerate. But if you want to regenerate them without uploading new files, simply goto your ftp and delete all the image files from the image/cache folderNow I am trying to change the size on the settings page but I guess after the images have been cached you can no longer change them. Is there any way to delete the cache and have it rebuilt other then re-uploading all the photos in the store.
Just to add to this...
If I delete what is in my cache - it never comes back.
Does OC generate those cache files when they are requested? I just tested your instructions out in 1.3.2 and when I deleted everything (mind you this is a fresh install of OC 1.3.2 with the image folder restored from previous version). I called the 'frontpage' and no product images appear. I log in to my server through SSH and there are no files present in the cache directory. The cache directory has the proper permissions.
If I delete what is in my cache - it never comes back.
Does OC generate those cache files when they are requested? I just tested your instructions out in 1.3.2 and when I deleted everything (mind you this is a fresh install of OC 1.3.2 with the image folder restored from previous version). I called the 'frontpage' and no product images appear. I log in to my server through SSH and there are no files present in the cache directory. The cache directory has the proper permissions.
Kevin Davidson
Purolator Shipping Module
Canpar Shipping Module
VQMod - Paypal Transaction ID to Payment Details
Qphoria,
Thanks, my case it was my fault. I didn't set my log file. After I set a name for my log file it started to work. I didn't realize that it was required at the time for testing.
Thanks!
Thanks, my case it was my fault. I didn't set my log file. After I set a name for my log file it started to work. I didn't realize that it was required at the time for testing.
Thanks!
Kevin Davidson
Purolator Shipping Module
Canpar Shipping Module
VQMod - Paypal Transaction ID to Payment Details
Yes, I did realize that the cache rebuilds itself and it only was not working because I tried a sized of "900xnothing". I took a look at the image_resize function in the image helper. I understand why uniform sizes on thumbnails is important but on the larger pictures it ends up making them quite smaller if they are not exactly that size. For example I have an artist who wants to show their artwork which has writing on it. All the artwork are canvas prints roughly 900x600. Some other products are not the same size.
When I upload a 900x600 photo the photo will be padded with white space to make it 900x900. Then when the user clicks on the photo thickbox makes it quite smaller because it is so tall when really it should have been only 600px tall or smaller. This makes the artwork unreadable because when padded the artwork is 400x400 in thick box. I did change the size to 900x600 on the settings page and on my resolution monitor the photos are now a nice 800px wide. If there were a resize by drop down on the image settings users can choose the behavior of the resizing at least on the large photos.
When I upload a 900x600 photo the photo will be padded with white space to make it 900x900. Then when the user clicks on the photo thickbox makes it quite smaller because it is so tall when really it should have been only 600px tall or smaller. This makes the artwork unreadable because when padded the artwork is 400x400 in thick box. I did change the size to 900x600 on the settings page and on my resolution monitor the photos are now a nice 800px wide. If there were a resize by drop down on the image settings users can choose the behavior of the resizing at least on the large photos.
Henry Weismann
877.44.MY.WEB (877.446.9932)
We can help with your Opencart Site - Opencart Web Developer
I"m not sure if this is what you're looking for or not, but I rewrote the resize function of the Image class. It will now create an image with the aspect ratio of the original with no added "letterboxing."
As others noted however, this may screw up the alignment of your catalog. You'll need to fix this in your theme. I did it because I wanted to put a drop shadow on my images.
system/library/image.php
As others noted however, this may screw up the alignment of your catalog. You'll need to fix this in your theme. I did it because I wanted to put a drop shadow on my images.
system/library/image.php
Code: Select all
public function resize($width = 0, $height = 0) {
if (!$this->info['width'] || !$this->info['height']) {
return;
}
$xpos = 0;
$ypos = 0;
$scale = min($width / $this->info['width'], $height / $this->info['height']);
if ($scale == 1) {
return;
}
$new_width = (int)($this->info['width'] * $scale);
$new_height = (int)($this->info['height'] * $scale);
$xpos = (int)(($width - $new_width) / 2);
$ypos = (int)(($height - $new_height) / 2);
$image_old = $this->image;
$this->image = imagecreatetruecolor($new_width, $new_height);
//$background = imagecolorallocate($this->image, 255, 255, 255);
//imagefilledrectangle($this->image, 0, 0, $width, $height, $background);
imagecopyresized($this->image, $image_old, 0, 0, 0, 0, $new_width, $new_height, $this->info['width'], $this->info['height']);
imagedestroy($image_old);
$this->info['width'] = $new_width;
$this->info['height'] = $new_height;
}
Hi,
I've used this code in system/library/image.php and it has worked, so I now have no added white space which is great. However, the images appear rather jagged now. Have you got any idea why this could be?
I'm using v.1.4.91 by the way. I'm also using the watermark mod, so I had to modify the image.php file in that if itmakes any difference.
Thanks,
Dan
I've used this code in system/library/image.php and it has worked, so I now have no added white space which is great. However, the images appear rather jagged now. Have you got any idea why this could be?
I'm using v.1.4.91 by the way. I'm also using the watermark mod, so I had to modify the image.php file in that if itmakes any difference.
Thanks,
Dan
To fix the jagged issue change this line
imagecopyresized($this->image, $image_old, 0, 0, 0, 0, $new_width, $new_height, $this->info['width'], $this->info['height']);
with this line
imagecopyresampled($this->image, $image_old, 0, 0, 0, 0, $new_width, $new_height, $this->info['width'], $this->info['height']);
Basically you want it to resample the image not use resized
imagecopyresized($this->image, $image_old, 0, 0, 0, 0, $new_width, $new_height, $this->info['width'], $this->info['height']);
with this line
imagecopyresampled($this->image, $image_old, 0, 0, 0, 0, $new_width, $new_height, $this->info['width'], $this->info['height']);
Basically you want it to resample the image not use resized
Hi I am on latest version of OC and got the same problem. dragonxeon's solution of replacing with 'imagecopyresampled' is already part of default code, tried deleting image cache too! Any ideas?
Someone?
Someone?
>> search before you post and [solved] when solved
>>Opencart v1.5.1.3, php 5.1.6, Apache/2.2.3 (CentOS)
I am using v1.5.1.3 I changed the code as Bryan76 and dragonxeon suggested and it worked perfectly. I did go through and deleted all the cached image thumbnails that had already been made (/image/cache/data).
I have been trying for quite sometime to get the white letterbox effect to not display since I have a black background. Thanks to the both of you!
I have been trying for quite sometime to get the white letterbox effect to not display since I have a black background. Thanks to the both of you!
Hello,
New to OpenCart and this forum.
First, thank you very much for making this. It works great!
Second, I converted it to vqmod and here it is
New to OpenCart and this forum.
First, thank you very much for making this. It works great!
Second, I converted it to vqmod and here it is
Who is online
Users browsing this forum: No registered users and 66 guests