SocialEngine 4: Uploaded Images Take More Memory than Original Files

The default behavior of the albums plugin has a quality setting of 100, whereas many images downloaded from the internet are highly compressed.

By reducing the quality of the album plugin’s output, you can reduce resulting filesizes. This is independent of the photos resolution, meaning that this solution in no way effects the pixel dimensions of the image. This setting is discretionary, and lower settings may result in less desirable image distortion. To reduce the quality of the jpeg output:

  • 1

    Open ./include/class_upload.php in your editor of choice.

  • 2

    Around line 174, find the code:

     // RESIZE IMAGE AND PUT IN USER DIRECTORY switch($this->file_ext) { case "gif": $file = imagecreatetruecolor($width, $height); $new = imagecreatefromgif($this->file_tempname); $kek=imagecolorallocate($file, 255, 255, 255); imagefill($file,0,0,$kek); imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $this->file_width, $this->file_height); imagejpeg($file, $photo_dest, 100); ImageDestroy($new); ImageDestroy($file); break; case "bmp": $file = imagecreatetruecolor($width, $height); $new = $this->imagecreatefrombmp($this->file_tempname); for($i=0; $i<256; $i++) { imagecolorallocate($file, $i, $i, $i); } imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $this->file_width, $this->file_height); imagejpeg($file, $photo_dest, 100); ImageDestroy($new); ImageDestroy($file); break; case "jpeg": case "jpg": $file = imagecreatetruecolor($width, $height); $new = imagecreatefromjpeg($this->file_tempname); for($i=0; $i<256; $i++) { imagecolorallocate($file, $i, $i, $i); } imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $this->file_width, $this->file_height); imagejpeg($file, $photo_dest, 100); ImageDestroy($new); ImageDestroy($file); break; case "png": $file = imagecreatetruecolor($width, $height); $new = imagecreatefrompng($this->file_tempname); for($i=0; $i<256; $i++) { imagecolorallocate($file, $i, $i, $i); } imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $this->file_width, $this->file_height); imagejpeg($file, $photo_dest, 100); ImageDestroy($new); ImageDestroy($file); break; }
    3

    In each instance of imagejpeg($file, $photo_dest, 100); change the “100″ to the desired quality, on a scale of 0-100. Smaller numbers will result in lossy-er image quality, but smaller file sizes.

    Note: Reducing the quality is discretionary, and lower settings may result in less desirable image distortion.

    More Info

    Looking for quality Social Engine Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , , , , , , , , , | Posted under SocialEngine | RSS 2.0

Author Spotlight

Andrew Cross

Andrew Cross

Hi, I'm Andrew. A am a 25, ICT Administrator which offers support to company's around the South Wales Area. I have created a few social sites for myself and other company's. So far 2 out of 3 have been successful using the powerful SocialEngine Script. I continue to try and help the community of SocialEngine by giving Support and Technical Help where possible.

2 Comments on SocialEngine 4: Uploaded Images Take More Memory than Original Files

  1. GG says:

    That’s great. Can you also explain how you can activate animated .gifs on SE4 PHP?

Leave a Reply

Your email address will not be published. Required fields are marked *


9 + = 10

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>