Hi David,
I have about 750k products. As many merchants supply only huge images, even cached, many will be over the 25k size you mentioned in another thread to estimate disk storage size. I began to do this with products and stopped as I saw images 100k and over. Is there any way to optimize these images on the server and replace in the cache?
Actually, this is the version I've been using, but only with featured. I manually optimized to bring down size, so now average 30-32k.
I experimented with products, but deleted after seeing the resized image sizes, which many were over 100k. Certainly can't manually optimize.
I'm probably misunderstanding, but if I use with both search results & product, does that create 2 cached images of same product? If so, is there some way for product images to utilize cached search result images? If this is database intensive, don't even bother w/code :-)
Hi,
If you use imageCache.php for both Featured Products and for the main product image, there would only be 1 cached image file created as the URL and therefore the hash used to create the cache filename will be the same.
I'm surprised at the images sizes after resize being so large - what resize dimension do you have configured in imageCache.php e.g.
$imageCacheResize = 250;
...and could you perhaps let me know an example product image URL that is coming in at over 100K after resizing? (i'll remove link before publishing your reply...)
Thanks,
David.
--
PriceTapestry.com
I regenerated unoptimized images on Featured page. What I see from comparing merchant / cache images is that smaller size jpgs become larger pngs. And larger jpgs don't reduce very well (a 242kb jpg > 125.6kb png). Actually, you can pull any image from feature and product pages to compare sizes as product page images aren't cached (I disabled for product pages). Here is sample info/links:
{code saved}
Hi,
I'll check the sources out later but I just wanted to suggest one thing to try quickly - in the imageCache.php script the re-sized image is output as png using this code;
imagepng($new);
....it might be worth experimenting with JPEG format instead, simply REPLACE with:
imagejpeg($new);
Cheers,
David.
--
PriceTapestry.com
When I added new items, it worked. File sizes now tiny (most under 11k)!
However, some of the image quality is not good (last 3 rows are new jpegs): {link saved}
1. Next to last row, click image to see product page to compare. The default quality is 75 in GD, found this to increase quality:
imagejpeg($im, NULL, 90);
imagedestroy($im);
2. The very last image has black showing top/bottom (but not on product page). How can I make background all white?
Hi,
To include the quality parameter, simply use that code directly in imageCache.php at line 79:
imagejpeg($im, NULL, 90);
Regarding the image with black borders, I'm not quite sure where this is coming from as it doesn't appear to be part of the image (and as you say it is fine on the product page!) However, if it is an artifact of scaling, the first thing I would suggest is to try a slightly different dimension, for example if you are using;
$imageCacheResize = 250;
...try:
$imageCacheResize = 256;
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
image quality code never worked, returned "default quality" no matter what setting I used, so deleted it. Changed Resize to Resample, that works _super_. Trying to add a little sharpening, no joy.
I've tried several different things, not getting results. What I'm working with now:
{code saved}
1. Where should the sharpening code be placed?
2. Does it need to be altered to work with imageCache.php?
3. The example code does have _return $img;_ as the last line, but as I saw that further down in your code, left it out. I placed closing brace where it is now and also tried adding after your code. Neither made any difference. Where should the function imagesharpen closing brace be placed?
4. Should I use $img or $new?
+ any & all advice (will sharpening will cause too much load/use too much memory, etc.) is greatly appreciated.
Hi,
Position your imagesharpen function at the top of the script, and you will need to add the return value at the end of the function (immediately following call to imageconvolution)...
return $new;
And then insert the call just before the call to imagejpeg(), so you will have:
$new = imagesharpen($new);
imagejpeg($new);
Cheers,
David.
--
PriceTapestry.com
Hi David,
Worked a charm after I revised
$new = imagesharpen($new);
imagejpeg($new,null,90);
Regarding black border...it's actually a black background. I happened to find another merchant using a very small image inside a 300x300 png with a large transparency. Example at bottom: {link saved}
I checked imageCache, background is set to white, haven't touched.
$new = imagecreatetruecolor($imageCacheResample,$imageCacheResample);
$newBackground = imagecolorallocate($new,255,255,255);
imagefill($new,1,1,$newBackground);
Does anything need to be changed if merchant supplies png and I'm converting to jpeg?
Hi,
I know you have been using imageCache.php for some time so may not be at the latest version which includes re-sizing so that might do the trick. Note that the latest version uses Base 64 encoding to transfer the image URL - if you are currently using urlencode(), to avoid having to modify your html/ files, where the latest version has this code:
$src = base64_decode($_GET["src"]);
...REPLACE with:
$src = $_GET["src"];
Cheers,
David.
--
PriceTapestry.com