• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Image compression

koodry

Chevereto Member
Hello, I'm trying to upload two pictures.

2600x1200 after loading the file size was reduced by 60%
1920x1080 after loading the file size has not changed.

Why the second file is not changed? How to change this?

I tried to change this line. This only works for the first file .

class.upload.php
PHP:
imagejpeg($image, $image_filename, 90);
 
Anyway. Compression works of original images, apparently only for the big picture. I uploaded this picture to your site. Before upload size was 1.31 mb (jpg), now 221 kb (jpg).

Because you do not want to help me. I solved my own problem.

I made the conversion BMP and PNG to JPG and all pictures are made with 90% quality

Replaced this code:
PHP:
// BMP?
        if($this->source_image_fileinfo["extension"] == "bmp") {
            $this->ImageConvert = new ImageConvert($this->downstream, "png", $this->downstream);
            $this->downstream = $this->ImageConvert->out;
            $this->source_image_fileinfo = G\get_image_fileinfo($this->downstream);
        }

for this

PHP:
// JPG?
        if($this->source_image_fileinfo["extension"] == "jpg") {
            $this->ImageConvert = new ImageConvert($this->downstream, "jpg", $this->downstream, 90);
            $this->downstream = $this->ImageConvert->out;
            $this->source_image_fileinfo = G\get_image_fileinfo($this->downstream);
        }       
        // BMP?
        if($this->source_image_fileinfo["extension"] == "bmp") {
            $this->ImageConvert = new ImageConvert($this->downstream, "jpg", $this->downstream, 90);
            $this->downstream = $this->ImageConvert->out;
            $this->source_image_fileinfo = G\get_image_fileinfo($this->downstream);
        }
        // png?
        if($this->source_image_fileinfo["extension"] == "png") {
            $this->ImageConvert = new ImageConvert($this->downstream, "jpg", $this->downstream, 90);
            $this->downstream = $this->ImageConvert->out;
            $this->source_image_fileinfo = G\get_image_fileinfo($this->downstream);
        }

works fine.
 
This for example: http://demo.chevereto.com/image/WH original filesize is 1.2MB which is same size as uploaded is 1.2MB. Now in some cases you see things like this: http://demo.chevereto.com/image/WU which local size is 1.9 MB but uploaded file is 1.7MB and that is because the original image has exif data telling the orientation of the photo. When you upload an image and its orientation needs to be fixed (otherwise people will see the image rotated) the script rotate that image and save it at 90% quality. You can check that function in class.upload.php, the method is called fixImageOrientation.

Why 90%? Because that is the most usual compression today (in the past was 70%). The quality argument in the GD functions doesn't actually refers to the original image but to a newly created image. So if you save an image at 100% is not that you are saving it as the original, is that the new image that you are creating has no compression so the file will be larger. Is a real bummer because GD functions can't tell us the compression quality of a given image (and no one can, jpg doesn't have a compression index or something that tells you the compression used).

When I told you that is not recommended is because making the 90% assumption puts you in a situation where if the file was created with quality below 90% (for instance, 70% or 50%) you will be upscaling the quality and then getting larger files. Is like when you have a MP3 at 64kbps and convert it to 320kbps, the only thing that you will gain is size. This is the same thing, all the images below 90% quality will generate larger files for you.

By the way, is not that I didn't want to help you, is that you ask me for something and I told you the short summary "is not recommended".

Cheers.
 
Last edited:
This works for both "original" and "medium size" PNG converted to jpg 90%. But i want to keep the original uncompress, how to compress the "medium size" only for 90%?
 
This works for both "original" and "medium size" PNG converted to jpg 90%. But i want to keep the original uncompress, how to compress the "medium size" only for 90%?
You can't because the system uses a chain with the same file extension. Until I change that, there won't be what you are asking. Don't worry, I'm working on it.
 
Back
Top