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; }
3In 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
-
http://en.wikipedia.org/wiki/JPEG This article explores the concept of JPEG compression ratios.
-
http://www.php.net/function.imagejpeg This article explore the use of the imagejpeg command, responsible for creating jpeg images in the album plugin.
Looking for quality Social Engine Web Hosting? Look no further than Arvixe Web Hosting!
-
That’s great. Can you also explain how you can activate animated .gifs on SE4 PHP?
At this moment in time animated gifs cannot be processed on SE, SE hope to enable this in further releases
SE currently do not support GIFs