Page 1 of 1

product images and white space [SOLVED]

Posted: Fri Sep 09, 2011 1:21 pm
by batgrl
I am using a dark-themed template. When images are resized for the various placements (prod, cat, etc) the sides show white. (Nothing new).

However, I sell books and cds.

While this is OK for CDs which are square, it really looks bad for books.

Is there a code to allow for one dimension to auto-config proportionately?

Example:
width = 200 px
height = calculated from the original to whatever the proportional height would be.

Thank you.

Re: product images and white space

Posted: Fri Sep 09, 2011 5:34 pm
by uksitebuilder
Not 100% on this, so backup first

open: system/library/image.php

find

Code: Select all

		if (isset($this->info['mime']) && $this->info['mime'] == 'image/png') {		
			imagealphablending($this->image, false);
			imagesavealpha($this->image, true);
			$background = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
			imagecolortransparent($this->image, $background);
		} else {
			$background = imagecolorallocate($this->image, 255, 255, 255);
		}
		
		imagefilledrectangle($this->image, 0, 0, $width, $height, $background);
change to

Code: Select all

		if (isset($this->info['mime']) && $this->info['mime'] == 'image/png') {		
			imagealphablending($this->image, false);
			imagesavealpha($this->image, true);
			$background = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
			imagecolortransparent($this->image, $background);
		} else {
			$background = imagecolorallocate($this->image, 1, 1, 1);
		}
		
		imagefilledrectangle($this->image, 0, 0, $new_width, $new_height, $background);


Re: product images and white space

Posted: Sat Sep 10, 2011 2:30 am
by batgrl
It worked, however, it ONLY works for PNG images saved at 24 bit, transparent. So, I will have to go back and save all my JPGs as PNG files using a transparent photoshop layer, which is fine, but a little time consuming.

Thank you.

Re: product images and white space [SOLVED]

Posted: Mon Sep 02, 2024 4:38 pm
by tingwing
it works