Keyword

Prevent changes to images by K2 upload

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
3 weeks 5 days ago #178665 by Goble002
Prevent changes to images by K2 upload was created by Goble002
Hi,

My original images are 72dpi / 86 image quality for a size of about 3.5Mb. When K2 upload it in the media/k2/items/src it become 96dpi / 100 image quality for a size of about 9.5Mb. Is it possible to prevent image size and name to be changed by k2 upload ?

These images are also used by another extension for image download so I can't delete them.

Please Log in or Create an account to join the conversation.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
3 weeks 4 days ago #178671 by Fotis
Replied by Fotis on topic Prevent changes to images by K2 upload
Images are renamed for a reason. This cannot change. Alternatively, you can use a 3rd party plugin to do that: www.firecoders.com/joomla-extensions/econa

As for the quality, adjust it in K2's component settings ("Images" tab).

Source images are kept in /media/k2/items/src/ because you can re-use them in the future to re-create your images based on new dimensions, by using a script like this: github.com/getk2/rebuildK2imageCache

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

Please Log in or Create an account to join the conversation.

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
3 weeks 4 days ago - 3 weeks 4 days ago #178676 by Goble002
Replied by Goble002 on topic Prevent changes to images by K2 upload
Fotis,

I can understand the reasoning behind keeping source file. My point is about why they have to be readjusted in quality (during upload) ?  If my source file is 90 in image quality, it can be uploaded as is, then the file can be resized by K2 (for front-end use) as per K2 image settings in back-end.

If you upload an image of quality 90, it makes no sense for me to convert it to 100. The quality won't get better. It will just increase the size unnecessarily. And in my case bring a 3.5Mb file to 9.5Mb. For 100s of photos you can imagine the nightmare...

P.S For Econa, it doesn't apply to me since I'm taking care of editing my pictures myself.

Maybe I can adjust the class upload.php file from Verot ? However jpg quality settings here are set to 85 (last line).

        $this->file_max_size_raw = trim(ini_get('upload_max_filesize'));
        $this->file_max_size = $this->getsize($this->file_max_size_raw);

        $this->image_resize             = false;    // resize the image
        $this->image_convert            = '';       // convert. values :''; 'png'; 'jpeg'; 'gif'; 'bmp'

        $this->image_x                  = 150;
        $this->image_y                  = 150;
        $this->image_ratio              = false;    // keeps aspect ratio with x and y dimensions
        $this->image_ratio_crop         = false;    // keeps aspect ratio with x and y dimensions, filling the space
        $this->image_ratio_fill         = false;    // keeps aspect ratio with x and y dimensions, fitting the image in the space, and coloring the rest
        $this->image_ratio_pixels       = false;    // keeps aspect ratio, calculating x and y so that the image is approx the set number of pixels
        $this->image_ratio_x            = false;    // calculate the $image_x if true
        $this->image_ratio_y            = false;    // calculate the $image_y if true
        $this->image_ratio_no_zoom_in   = false;
        $this->image_ratio_no_zoom_out  = false;
        $this->image_no_enlarging       = false;
        $this->image_no_shrinking       = false;

        $this->png_compression          = null;
        $this->jpeg_quality             = 85;
Last edit: 3 weeks 4 days ago by Goble002.

Please Log in or Create an account to join the conversation.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
3 weeks 3 days ago #178690 by Fotis
Replied by Fotis on topic Prevent changes to images by K2 upload
When you upload to resize an image, you should be able to set a given quality percentage. GD however is not the best image processor and as such can result in larger files in some cases, e.g. if you upload a carefully crafted 1000px image (on Photoshop) and the resizing is also 1000px. The resulting file will be larger indeed. But this is an edge case. People use K2 so they don't have to care about image processing. Upload the image and off you go.

P.S. The code you see are the defaults of that class. There are overridden when the class is called.

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

Please Log in or Create an account to join the conversation.

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
3 weeks 3 days ago #178698 by Goble002
Replied by Goble002 on topic Prevent changes to images by K2 upload
Thanks Fotis,

really appreciate your time and effort for reverting back.

People use K2 so they don't have to care about image processing. Upload the image and off you go.

Yes indeed but again we are taking about the source file here. May be my case is special ;-).

I found the file where I can override the image quality. I have checked src and cached files, everthing's working prefectly. My 2,337Kb image only grows by 110Kb now.
 

Please Log in or Create an account to join the conversation.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
3 weeks 3 days ago #178703 by Fotis
Replied by Fotis on topic Prevent changes to images by K2 upload
OK, so this is the code in K2 that handles the source image upload:

github.com/getk2/k2/blob/master/administrator/components/com_k2/models/item.php#L262-L268

As you can see, we enforce a conversion to .jpg and set the quality to 100%. My guess is that GD does *some* processing, which would explain the slight increase in file size.

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum