Post by Freya » Tue Feb 16, 2010 12:54 am

How to change this.
I was searching the complete forum, was asking 2 times, but didn't get any help with this issue.

All thumbnails have a white border and i was working for days (not only hours) with the CSS, but wasn't able to get rid of this *grrr* white border.

So where in the world is it written, that the thumbails get the white border from?

I found out, if i upload a picture in exactly the size, i set in the settings, there is no white border.
But there MUST be another way, to get the order for the white border away.
So please, pretty pretty please, Daniel show up and tell me the secret.
Tell me (and many, many other users, who have asked before) how to get rid of this white border.

Thank you
Freya
Last edited by i2Paq on Tue Feb 16, 2010 4:10 pm, edited 2 times in total.
Reason: Changed the title

Newbie

Posts

Joined
Tue Feb 02, 2010 8:36 pm


Post by Freya » Tue Feb 16, 2010 4:01 am

Moved but not answered?????

This is, in my eyes, NOT a template question, cause if this would be to find in the CSS, i would already had found the white border.
I changed EVERY white color, except the text color, and the white border is STILL there.
Event though i pointed on, if i set the image size to 250 x 250 (e.g) and load up a picture in exactly the same this, there is no white border.
So it have to be found somewhere else in the script, but not in the template.

And i can't ask all the vendors to do all promotion pictures again in a smaller size.

So please, tell me where i can change it and i'm very satisfied.

Newbie

Posts

Joined
Tue Feb 02, 2010 8:36 pm


Post by Freya » Tue Feb 16, 2010 4:12 am

Hello,

i just wonder.
I posted a question, that have nothing to do with the template. And for sure, i was working damned long with the CSS, without being able to solve the problem.
I was searching the forum and found a lot people, who had exactly the same question, but never got any satisfying answer.

Now my post have been moved into the template-forum, and i would like to know why!
If the moderator is so sure about, that this have something to do with the template, so why didn't he answer the question after moving?
Or are the words "white border" reason enough to move a post?
Sorry, if i sound aggressive, but i'm more than disappointed.

Anyone, at least this/that person/s, who wrote the script, should know, how to solve the problem.
Where are they?

And can please one of them solve the problem?

Newbie

Posts

Joined
Tue Feb 02, 2010 8:36 pm


Post by i2Paq » Tue Feb 16, 2010 5:33 am

If you would have looked at your own topic it says on the bottom that it has been moved and by who; Me.
I have also edited the title and the first line as it was unpolite and addressed to Daniel directly.

I've also merged your 2 topics as asking the same question twice is not necessery.

Moving a topic does not means it also got to have an answer.

Looking at other topics and your question in particolare it has all to do with the look of your shop, aka the cosmetic look and therefore I think it is better of in the Template section. If you feel differend that is OK by my.
Maybe the next time you put up a question it would come handy if you would let us know which version of OpenCart and if the default template is used or a modified one. This to be more specific for anyone here to help you solve the question.

This is a forum where people ask and answer questions on a free base. This means that questions can be left unaswered or the answer will come in a few days. Just be patient.
Freya wrote:I found out, if i upload a picture in exactly the size, i set in the settings, there is no white border.
But there MUST be another way, to get the order for the white border away.
To me the "problem" lies in the fact that if your picture is smaller then the frame it is in it will create that white space. Therefore you need to:

1. Make sure the picture has the right size.
2. Make sure you devine a backround color for that frame in your css, because I think it is not there atm. and thus you will see the white color.

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by Freya » Tue Feb 16, 2010 6:31 am

Thanks for your answer.

But sorry, my topic was everything, but not unpolite. I didn't used mean words, only my thought, that at least he should know. With this i said, that i'm the meaning, he have the best knowledge. THIS is unpolite?
Or did i see too much in him? Sorry, my fault.

Many people have asked this question before, not one got an satisfying answer. Strange, isn't it? Even though, they wrote, what version and template they used.

I even haven't resized the pictures and for me it's strange, very strange, when i load up picture with 800 x 600 px and there is still a white border around a 200 x 200 px image.
And the background is black, only few parts are red, that makes white borders?

Answer is not in need, cause in this case there is no answer!

Thanks at least for this wonderful shop, even though it seems, i have to live with this borders, this is the best shop i ever found.

Good luck for the future

Newbie

Posts

Joined
Tue Feb 02, 2010 8:36 pm


Post by fido-x » Tue Feb 16, 2010 7:58 pm

This is not a "border", it is a background colour.

OpenCart resizes your original image files to the sizes you specify in the settings in the administration. Your images are resized proportionally and centred within the size specified, the remaining background colour is the "white border" you are talking about.

The background colour for the resized image is set in the file "system/library/image.php" at line 75:

Code: Select all

$background = imagecolorallocate($this->image, 255, 255, 255);
You can change the colour by changing the RGB values (eg., 255, 255, 255 is white, 0, 0, 0 is black).

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Freya » Wed Feb 17, 2010 10:43 pm

Thank you so very much fido-x :)
Thanks for the help and to lead me to the right place to change it.
I could have searched for years in the CSS, when it isn't to find there.

Btw. it feels good, not to stand there like an idiot, because others wanted to tell me, it's in the CSS, event though i couldn't find it there.

Newbie

Posts

Joined
Tue Feb 02, 2010 8:36 pm


Post by CF_Pro » Wed Jun 15, 2011 1:49 am

I changed

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

how do I get the system to recreate the images using a black border.
I tried changing the dimensions, but that did not recreate them.

Any help is appreciated

Newbie

Posts

Joined
Wed May 04, 2011 6:25 am

Post by CF_Pro » Thu Jun 16, 2011 12:02 am

In case anybody is interested, you have to delete and reupload the image in your products manager.

Newbie

Posts

Joined
Wed May 04, 2011 6:25 am

Post by Glinja » Wed Jul 27, 2011 2:40 pm

fido-x wrote:This is not a "border", it is a background colour.

OpenCart resizes your original image files to the sizes you specify in the settings in the administration. Your images are resized proportionally and centred within the size specified, the remaining background colour is the "white border" you are talking about.

The background colour for the resized image is set in the file "system/library/image.php" at line 75:

Code: Select all

$background = imagecolorallocate($this->image, 255, 255, 255);
You can change the colour by changing the RGB values (eg., 255, 255, 255 is white, 0, 0, 0 is black).
will this not instead create a black line ???

Newbie

Posts

Joined
Mon Mar 14, 2011 1:37 am
Location - UK, London

Post by fido-x » Wed Jul 27, 2011 2:58 pm

No. Black would be "0, 0, 0". In other words, no colour. White is a combination of ALL colours. Hence, turning all RGB values to their maximum will give you white.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Glinja » Wed Jul 27, 2011 3:09 pm

fido-x wrote:No. Black would be "0, 0, 0". In other words, no colour. White is a combination of ALL colours. Hence, turning all RGB values to their maximum will give you white.
So what you are saying is that because black --> 0 --> no colours, changing 255 to 0 will make the white lines transparent?

Sorry I would test but no access to my FTP at this precise moment.

Newbie

Posts

Joined
Mon Mar 14, 2011 1:37 am
Location - UK, London

Post by fido-x » Wed Jul 27, 2011 4:51 pm

Glinja wrote:So what you are saying is that because black --> 0 --> no colours, changing 255 to 0 will make the white lines transparent?
No. What I'm saying is, if you set all RGB values to their minimum (ie. "0") you will get black. This is NOT transparent.

Technically black and white (and all greys) are not colours, they are "shades".

If you want your image to have a transparent background when it is resized, you need to start with an image that has a transparent background to begin with. The transparency will be retained when the image is resized.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by AWOL » Fri Oct 21, 2011 7:08 pm

Part of the problem you are experiencing might be related to the way in which aspect ratios are calculated. Resizing an image with a 4:3 aspect ration in Adobe Fireworks from 400x300 pixels to a 160 pixel wide image will calculate the height to be 119 pixels. If you use these dimensions to define your thumbnail size Opencart will (correctly) add a border to the sides of the image.

What you need to do is to make sure the aspect ratio is properly calculated for images that are to be resized. There's an aspect ratio calculator at http://andrew.hedges.name/experiments/aspect_ratio/

Newbie

Posts

Joined
Sat Jan 26, 2008 8:54 am

Post by goldsonu » Mon Nov 21, 2011 8:26 pm

try this one solved your problem...

$scale_w = $width / $this->info['width'];
$scale_h = $height / $this->info['height'];

if ($scale_w == 1 && $scale_h == 1) {
return;
}

$new_width = (int)($this->info['width'] * $scale_w);
$new_height = (int)($this->info['height'] * $scale_h);

Newbie

Posts

Joined
Tue Oct 04, 2011 9:23 pm
Location - kuwait

Post by alaskaberries » Mon Dec 26, 2011 12:36 am

I too scoured the forum for the same issue of white showing up around my images and found many threads with this one looking like the best one to help with my problem.. I am using 1.5.1.3 with the default template.

It was stated to look for this code and change the rgb values. I did that to just the one line but it did not work.

Code: Select all

$background = imagecolorallocate($this->image, 255, 255, 255);
I noticed my code line had this:

Code: Select all

			$background = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
			imagecolortransparent($this->image, $background);
		} else {
			$background = imagecolorallocate($this->image, 255, 255, 255);
		}
Do I need to change both instances where it shows 255,255,255? to a color such as my background rgb color?
All of my images were uploaded as .jpg. I did edit one to a .png and uploaded it and it did not show the white border. I realize this is a solution but I really do not want to have to edit sooo many images.

User avatar
New member

Posts

Joined
Sun Nov 27, 2011 12:31 am

Post by fido-x » Mon Dec 26, 2011 4:00 pm

alaskaberries wrote:

Code: Select all

			$background = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
			imagecolortransparent($this->image, $background);
		} else {
			$background = imagecolorallocate($this->image, 255, 255, 255);
		}
Do I need to change both instances where it shows 255,255,255? to a color such as my background rgb color?
No. The first part (before the "} else {" deals with the tranparancy and sets white as the tranparent colour (applies to .gif and .png files). The bit after the "} else {", deals with the background colour for images without a transparency, eg., .jpg images.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by alaskaberries » Mon Dec 26, 2011 11:39 pm

Perfect, that cleared it up for me. Saved me a huge amount of time not having to convert all of my jpg to png. Much appreciated fido-x!

User avatar
New member

Posts

Joined
Sun Nov 27, 2011 12:31 am

Post by fido-x » Thu Dec 29, 2011 9:15 am

Image sizes can be set under the store settings in the administration (under the "Image" tab). By default these are "square" (ie. an aspect ratio of 1:1). If all your images have, for example, a 4:3 aspect ratio , then all you have to do is reflect this ratio in the image dimensions you set in the admin. For example, change 120 x 120 to 120 x 90. No "core hacks" required.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by fido-x » Thu Dec 29, 2011 10:44 am

blackhalo wrote:
fido-x wrote:Image sizes can be set under the store settings in the administration (under the "Image" tab). By default these are "square" (ie. an aspect ratio of 1:1). If all your images have, for example, a 4:3 aspect ratio , then all you have to do is reflect this ratio in the image dimensions you set in the admin. For example, change 120 x 120 to 120 x 90. No "core hacks" required.
Yes, I understand this... but it still doesn't work.
Yes it does!
blackhalo wrote:I have images with a 1px black border (ALL 4000 of my images)...
even when I use a ratio calculator, the images are still being stretched by one pixel.

It's quite obvious, because one side is always 2px thick...
while the other three sides are a clean 1px.
Which side, top or bottom?
Either way, it's easy to fix. Just reduce the "height" by 1 pixel in the admin. Or, have a look in your stylesheet and get rid of any padding in the image class.
blackhalo wrote:Try it for yourself.
I have. It's the same method I use on my own site and I have NO problems.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia
Who is online

Users browsing this forum: No registered users and 5 guests