Post by batgrl » Fri Sep 09, 2011 1:21 pm

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.
Last edited by batgrl on Sat Sep 10, 2011 2:30 am, edited 1 time in total.

New member

Posts

Joined
Fri Sep 09, 2011 1:16 pm

Post by uksitebuilder » Fri Sep 09, 2011 5:34 pm

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);


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by batgrl » Sat Sep 10, 2011 2:30 am

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.

New member

Posts

Joined
Fri Sep 09, 2011 1:16 pm

Post by tingwing » Mon Sep 02, 2024 4:38 pm

it works

Active Member

Posts

Joined
Tue Aug 02, 2016 9:01 pm
Who is online

Users browsing this forum: No registered users and 3 guests