Page 1 of 2
Image Upload Jpeg Quality
Posted: 2012-03-14 16:36
by piskie
I have a problem with Image Upload and Resize.
All is well providing the Image needs downsizing. However if the Image is the same size or smaller than the target Width and Height settings, there is no resizing and the Jpeg quality remains as the original. This can be 100% or near resulting in a very large file stored on the server for the Web page to Load.
Example:
600x400 resized is typically 35k to 80k Averaging 45k
600x400 not resized some end up as large as 300k or even larger.
Is there a way to force the Upload and Resize function to set the Jpeg Quality even if the Image is not resized ??
I know I can put this onto a Client to better prepare their Images, but that is far from ideal.
Re: Image Upload Jpeg Quality
Posted: 2012-03-17 12:46
by Fred
Check the KT_config.inc file.
Should do the trick.
Re: Image Upload Jpeg Quality
Posted: 2012-03-17 14:32
by piskie
Thanks for the Reply Fred
However, having looked at that file (KT_config.inc) I can see no way to FORCE the Compression Quality Setting of an Image that is smaller than the Resize Target.
The KT_config.inc file allows me to set Compression Quality for "Resized" Images from it's default of 80%, but I can see no way to force process an Image smaller than the Target Size.
Either I am not clued up enough to see how to achieve ir or maybe You misunderstood my aims.
It seems to me that the place to achieve variations on Resize Criteria is likely to be KT_Image.class.php file. Now I am definitely not skilled enough to understand modify the functions in that File.
Re: Image Upload Jpeg Quality
Posted: 2012-03-17 16:13
by Fred
It works for me.
To confirm this I just tested with an image on one of my websites.
1. I grabbed an image from the site that is exactly 960X575 and 418kb in size.
2. I then set the image_quality in the config.inc file to "10". Yes I know it is extreme but I wanted to prove a point.
3. Re-upload the same image to the website. Remember it is already 960x575 to is is not going to resize it.
4. Result = Severely pixelated, image size is exactly 960x575 and file size now is 12.58kb
I am using the GD library.
Re: Image Upload Jpeg Quality
Posted: 2012-03-17 16:20
by Fred
Ok I manage to reproduce your problem,
You will have to add an additional function to compress the file regardless if you need to resize the file or not.
Looks like currently if the file is the same size or larger it will run the compression function. If anything smaller it will simply skip the reduction.
Re: Image Upload Jpeg Quality
Posted: 2012-03-17 17:03
by piskie
Thanks for all that effort Fred.
Yes, It is with an Image that is smaller than Target which gives me the problem.
The function that needs adding, any chance of some further assistance or guidance there.
Which file Is it in the KT_Image.class.php or KT_config.inc ??
Where does it go in the running order and what does it consist of ??
That's cheeky, I'm just about asking you to do it for me !!
Re: Image Upload Jpeg Quality
Posted: 2012-03-19 13:02
by Fred
It will be in the KT_Image.class.php
Looking at the file you probably only need to make sure that the image is actually checked and compressed.
Line 555
I think what is happening is the script check the size and exits if the image is smaller that the target,
Instead it should keep on running and compress the image.
The trick would be to find where it exits and stop it from doing so unless image quality is reduced.
Re: Image Upload Jpeg Quality
Posted: 2012-03-19 15:12
by piskie
Thanks Fred
I have looked at the KT_Image.class.php file but identifying and the bits that need to be modified and what needs doing, is beyond me.
However, while looking through that file, I did notice a function to increase or decrease Contrast.
It occurred to me that if I were able to set the Upload Function to carry out a minor tweak to the contrast, it would also set Compression Quality at the same time.
Am I on the right lines of a possible solution.
If so, how do I set the Contrast Adjust to a minimum step increase in Image upload to force it to process all images regardless of Size.
Re: Image Upload Jpeg Quality
Posted: 2012-03-19 16:12
by Fred
It is worth a try.
Unfortunately I do not have time to look at the problem right now as I made some mod_sec changes to my server and trying to finetune the rules.
Have a couple of issues that need my urgent attention.
i will visit this issue somewhere in the feature if you cant get it sorted as it potentially can save a lot of hard drive space and bandwidth. I know some of my clients reduce their images to smaller than what is required. Obviously that leaves the file size larger than what is necessary.
Re: Image Upload Jpeg Quality
Posted: 2012-03-19 16:39
by piskie
Thanks again Fred
I am putting this out to a Multi-Client directory site.
Each will have their own CMS with Image Upload.
This is the last hurdle to overcome before I can say it's finished and sign it off.
So if you could (at some time) give it some further thought, It would help me a lot.
At the moment, I can see no way to force a Contrast Tweak.
ADDT doesn't seem to have it in the User Interface.
I am assuming that I need to add a line in the Trigger Parrameters to set this requirement and amount.
Any chance of a gyess asto where and what I need to add to:
Code: Select all
//start Trigger_ImageUpload trigger
//remove this line if you want to edit the code by hand
function Trigger_ImageUpload(&$tNG) {
$uploadObj = new tNG_ImageUpload($tNG);
$uploadObj->setFormFieldName("fileField");
$uploadObj->setFolder("../meals/");
$uploadObj->setResize("true", 600, 400);
$uploadObj->setMaxSize(7000);
$uploadObj->setAllowedExtensions("jpg, jpeg");
$uploadObj->setRename("custom");
$uploadObj->setRenameRule("{auto}.jpg");
return $uploadObj->Execute();
}
//end Trigger_ImageUpload trigger
Cheeky I know, but if you have the info at your fingertips it would help save me some time.