Post by mikejones85 » Sat Jan 11, 2014 10:39 pm

Hi all

Wondered if I can pose a quick question. We've recently seen a slight up tick in visitors to our website but this has resulted in some high usage with our web host who has now warned us and is requiring us to reduce our usage.

I've been reviewing page load times across our site (http://www.stickerscape.co.uk) and think the primary issue are the wide range of images we have (the website is effectively an e-commerce site hence the large number of pictures). Recently, I've been limited the size of the original images to try to improve this. However, in reviewing page load times I've noticed that when Opencart creates a temporary image of a different size e.g. for category images or basket images, the cached version is several times larger than the original image.

For instance, I created an original image 500 x 500 (a PNG file) which was 37.3KB large. When reviewing page load times, the cached version for the category wide view was a file of 290 x 290 and was 329.4KB large! When this applied to large number of images on the site this is putting a lot of pressure on the servers.

Our site is running on Joomla with Aceshop (as the Opencart plugin). Does this sound typical however and if not, any have any thoughts on how to limit the file size of the cached images?

Any thoughts most welcome - thanks in advance.

Regards

Mike
Last edited by mikejones85 on Mon Jan 13, 2014 12:57 am, edited 1 time in total.

Newbie

Posts

Joined
Mon Jan 28, 2013 7:59 pm

Post by granddaddy » Sun Jan 12, 2014 1:17 am

It is better to use jpg for normal photo images. Png's are more suitable for logos.
If you have no choice and must use png, you can look at your code to see if 'png compression' is being used. But there are reports that sometimes a png will still be larger than before. You would have to make the change and then test a few file uploads (clearing the image cache first).

If you do want to try it, look in file:
system\library\image.php
for the function
public function save($file, $quality = 90)

In that function, look for the line:
imagepng($this->image, $file, 0);

To turn on compression, remove the comma and zero so it becomes:
imagepng($this->image, $file);

But if the zero has already been removed it means you have a more recent version where this change was made in the default source. If that's the case, your only option will be to use jpg's.

Active Member

Posts

Joined
Sat Feb 18, 2012 5:48 pm

Post by mikejones85 » Sun Jan 12, 2014 8:55 am

Thanks very much for your thoughts.

I have no real special requirement to use PNGs - I'd started using them at the outset as I found the images were crisper than JPEGs but hadn't appreciated how big the image size issue might become, especially with the cached images (or indeed at that stage how many images we may have!).

I'll have a look for the code as you suggest. By way of a follow-up question, by using JPEGs would the creation of the cached files that Opencart creates have a limited file size by default (rather than creating the larger PNG files)? (Appreciating that the original JPEGs will typically be smaller than the PNGs anyway).

Newbie

Posts

Joined
Mon Jan 28, 2013 7:59 pm

Post by billynoah » Sun Jan 12, 2014 10:12 am

pngs can be smaller in some cases depending on the complexity of the image. if you have photoshop you can use the "save for web" feature and get everything under 100k. thumbnails and such shouldn't be a problem.

you can also reduce the quality and use compression to get things smaller. regardless of your hosts restrictions it's still good practice to try to reduce the size of your images as much as possible for the sake of those viewing the site.

Image


Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm

Post by Shark » Sun Jan 12, 2014 7:00 pm

I use something like: http://www.opencart.com/index.php?route ... on_id=8684 (I had a free one, which I modificated myself, but can't remember where I found it, think it was this: http://www.pitgroup.nl/demo/smushit/SmushIt.txt). Saves me about 50-80 Mb for 500 products.

User avatar
Active Member

Posts

Joined
Sun Oct 31, 2010 9:43 pm
Location - Haarlem

Post by mikejones85 » Sun Jan 12, 2014 7:24 pm

Thanks again for your thoughts - all very helpful.

All images are saved for web - I generally target 100k for the file size (using PNGs) - product images are typically 500 x 500 in size. The strange bit is that I think the original file sizes are ok, the issue is when they're being resized they seem to jump significantly in size (even when the resizing is creating smaller thumbnails!).

Thanks for the extension though Shark - that appears to tick the box. I'm going to make an effort to changing some of the worst offending product images to JPEGs (some of the cached images are over 1mb from an original image of 200kb) - if that doesn't work I'll see what impact that extension might have.

Thanks again!

Newbie

Posts

Joined
Mon Jan 28, 2013 7:59 pm

Post by Shark » Sun Jan 12, 2014 8:02 pm

It's because opencart generates new images (by php gd-functions), which aren't optimized. I didn't try the paid version, let me know if it's any good. One problem I have with my own modification is that it sometime takes too long for an image to optimize which results in a blank image (can be very annoying). BTW I use this class in php:
smushit-php - a PHP client for Yahoo!'s Smush.it web service
Tyler Hall <tylerhall@gmail.com>
http://github.com/tylerhall/smushit-php/tree/master

User avatar
Active Member

Posts

Joined
Sun Oct 31, 2010 9:43 pm
Location - Haarlem

Post by billynoah » Mon Jan 13, 2014 12:06 am

@mikejones85 i'm not exactly sure what the problem is. I looked at your site and category images are around 32k. larger product images are still under 100k. where are these large images you were mentioning?

Image


Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm

Post by mikejones85 » Mon Jan 13, 2014 12:54 am

Hi Billy - thanks for your reply - I've been working all day to reduce the file sizes so suspect it's was fixed before you looked at them.

@Granddaddy post at the start of thread proved very useful - after making this tweak and clearing the cache the resized images were about a 1/10th of what they were previously (some were well over 2mb) to would recommend this fix to anyone having the same issue.

Newbie

Posts

Joined
Mon Jan 28, 2013 7:59 pm
Who is online

Users browsing this forum: Bing [Bot] and 367 guests