Page 1 of 1

[SOLVED]on the product page,how to make the auto-added white space for jpg product image to be black?

Posted: Mon Sep 02, 2024 4:47 pm
by tingwing
hi
on the product detailed page ,the showing product image would auto-add white space/side ,

how to make the white space/side to be black in order to be consistent with the website black background color?

thanks

Re: on the product page,how to make the auto-added white space for product image to be black?

Posted: Mon Sep 02, 2024 6:48 pm
by WaxedPerfection
a link would be good to view the area.

not loading >> http://www.bestshop24h.com/

Re: on the product page,how to make the auto-added white space for product image to be black?

Posted: Tue Sep 03, 2024 7:23 pm
by paulfeakins
tingwing wrote:
Mon Sep 02, 2024 4:47 pm
on the product detailed page ,the showing product image would auto-add white space/side ,
This question has been asked and answered many times, please search before posting.

Locking topic.

Re: on the product page,how to make the auto-added white space for product image to be black?

Posted: Mon Sep 09, 2024 12:10 pm
by tingwing
if using png image ,it is ok,the auto-add space's color is
the same as the background color

but if using jpg image,it is not ok,the auto-add space's color is different from the background color ,it is white color,how to change the auto-add white space to be black?

Re: on the product page,how to make the auto-added white space for product image to be black?

Posted: Mon Sep 09, 2024 12:31 pm
by softmonke
Open up "image.php" located in "system/library".

Look for the following code under the "resize" function, and change the "255, 255, 255":

Code: Select all

$background = imagecolorallocate($this->image, 255, 255, 255);
to whatever colour your background is using in rgb format. For example, if your website's background is rgb(0, 0, 0), then you should update it to:

Code: Select all

$background = imagecolorallocate($this->image, 0, 0, 0);

Re: on the product page,how to make the auto-added white space for product image to be black?

Posted: Mon Sep 09, 2024 12:44 pm
by tingwing
thanks for reply, what you said is the sam as what chatGPT4,i also feel it is the right solution ,but no good luck,still show white space.
i have go to system/library/image.php ,and change

Code: Select all

$background = imagecolorallocate($this->image, 255, 255, 255);
to

Code: Select all

$background = imagecolorallocate($this->image, 0, 0, 0);
and refresh the theme and SASS ,and refresh the modification and clear browser cache ...

Re: on the product page,how to make the auto-added white space for product image to be black?

Posted: Mon Sep 09, 2024 1:40 pm
by nonnedelectari
tingwing wrote:
Mon Sep 09, 2024 12:44 pm
thanks for reply, what you said is the sam as what chatGPT4,i also feel it is the right solution ,but no good luck,still show white space.
i have go to system/library/image.php ,and change

Code: Select all

$background = imagecolorallocate($this->image, 255, 255, 255);
to

Code: Select all

$background = imagecolorallocate($this->image, 0, 0, 0);
and refresh the theme and SASS ,and refresh the modification and clear browser cache ...
Deleted your old cached images?

Re: on the product page,how to make the auto-added white space for product image to be black?

Posted: Mon Sep 09, 2024 2:57 pm
by tingwing
thanks ,you are correct,now problem solved, yes ,need to go to delete all the images in image/cache

Re: on the product page,how to make the auto-added white space for product image to be black?

Posted: Mon Sep 09, 2024 4:34 pm
by JNeuhoff
Glad to hear you got it to work now. Please add '[SOLVED]' to the beginning of your original forum thread title.

Re: on the product page,how to make the auto-added white space for product image to be black?

Posted: Tue Sep 10, 2024 4:04 am
by softmonke
tingwing wrote:
Mon Sep 09, 2024 12:44 pm
thanks for reply, what you said is the sam as what chatGPT4,i also feel it is the right solution ,but no good luck,still show white space.
i have go to system/library/image.php ,and change

Code: Select all

$background = imagecolorallocate($this->image, 255, 255, 255);
to

Code: Select all

$background = imagecolorallocate($this->image, 0, 0, 0);
and refresh the theme and SASS ,and refresh the modification and clear browser cache ...
Just wanted to chime in and clarify that my solution did not come from ChatGPT. I prefer Claude nowadays anyway. :laugh: