Prevent image resize during uploading

See all posts Reply

Prevent image resize during uploading new!
by Goble002, 2 years, 11 months ago
Hi,

am a k2 user. The component (like you know) is using class.upload.php

I would like to prevent the source file from changing image quality and DPI after upload.
If my original file is 86 (image quality) and 72 dpi, the uploaded file will change to 100 (image quality) and 96 dpi. Make it the files 3 times bigger.

My settings are these (strangely) :
$this->jpeg_quality = 85;

P.S Am not a coder. ;-)Reply
Re: Prevent image resize during uploading new!
by colin, 2 years, 11 months ago
I am not sure what you mean. Can you provide here links to the source image and the result image, as well as the log produced by the class?Reply
Re: Prevent image resize during uploading new!
by Goble002, 2 years, 11 months ago
Thanks for you reply.

When you upload your original file in K2 component (on Joomla) :
it keeps a source file in /media/k2/items/src

then it will create other image of different sizes (as predefined in k2 settings in Joomla back-end) and place them in /media/k2/items/cache >>> These are OK.

My issue is with the uploaded source file, here's a copy :
http://test-photo.securemu.com/258ee2700b8562b5d51ebf2117179b3d.jpg
File: 6,071Kb | Image quality: 100 | DPI : 96 | Dimension : 3250 x 2171

My original file :
http://test-photo.securemu.com/test-photo-before-upload.jpg
File: 2,337Kb | Image quality: 86 | DPI : 72 | Dimension : 3250 x 2171

Like you can see the uploaded file settings change and become very big. Ideally I want the file to stay the same.

About the logs I don't know where to see that. However here is the full PHP :
http://test-photo.securemu.com/class.upload.php.zip

I can give you back-end and FTP access to a test website if I can PM you or mail you.Reply
Re: Prevent image resize during uploading new!
by colin, 2 years, 11 months ago
Thank you. The DPI has no meaning for a JPEG, but the image quaility is what makes the image very big. And I am afraid your issue lies with K2.

K2 is setting the JPEG quality to 100 when storing the first image:
https://github.com/getk2/k2/blob/8249eae20390c569a11521ef4f32f75f5376ab3b/administrator/components/com_k2/models/item.php#L264

Your only solution is to hack K2 as it is hardcoded.Reply
Re: Prevent image resize during uploading new!
by Goble002, 2 years, 11 months ago
Thank you so much ! Solved !Reply