Post by rgbrewer » Sat Aug 24, 2019 11:06 pm

3.0.2

system/library/image

public function resize ($width = 0, $height = 0, $default = '') {
[...]
$this->image = imagecreatetruecolor($width, $height)
}

This line should be
$this->image = imagecreatetruecolor($new_width, $new_height)

I believe the same error occurs here:
imagefilledrectangle($this->image, 0, 0, $width, $height, $background);

which I believe should be imagefilledrectangle($this->image, 0, 0, $new_width, $new_height, $background);

as well as here at the very end of the method
$this->width = $width;
$this->height = $height;

should be $new_width and $new_height

New member

Posts

Joined
Sat Apr 22, 2017 9:30 am

Post by rgbrewer » Sat Aug 24, 2019 11:30 pm

There's actually several problems with this code... here are my revisions that are currently working properly.

https://pastebin.com/2fx4vxA3
Last edited by rgbrewer on Sun Aug 25, 2019 12:00 am, edited 2 times in total.

New member

Posts

Joined
Sat Apr 22, 2017 9:30 am

Post by letxobnav » Sat Aug 24, 2019 11:38 pm

eh, no.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by rgbrewer » Sat Aug 24, 2019 11:46 pm

Thanks for your helpful thoughts.

I'm not making things up, this fails. Walk through it for this method call:
$image->resize(300);

what does $height equal when imagecreatetruecolor($width, $height) runs? It will evaluate to 0 and imagecreatetruecolor will fail because you cannot create an image that is zero pixels tall...

New member

Posts

Joined
Sat Apr 22, 2017 9:30 am

Post by letxobnav » Sun Aug 25, 2019 8:22 am

Well, you did not request helpful thoughts or an explanation as to why it works the way it does, you made an assertion, a flawed one.

The function of resize is to take an image of any size and any aspect ratio and resize it to fixed dimensions, as per admin settings, while maintaining that aspect ratio.
You however believe it should have a different function and thus claim it does not work correctly.

While there are better resize functions which can be written, which can do more magical things, that does not make your assessment any better.
So, eh, no.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by rgbrewer » Sun Aug 25, 2019 9:31 pm

The function has three default parameters, however if you try to use them, the function fails. You really trying to say that is an intended result? If the function requires three parameters to work -- and fails without all three parameters -- Why are the parameters optional? Can you explain that to me? If you can, I will apologize and delete my posts.

But you can't.

Don't be an obstinate jackass. My changes to this code is a marked improvement on the current code base, and there is no argument to be made that its not. You should be grateful that people come here and take time to help solve problems in the codebase, not troll with unhelpful two words replies based on your utter ignorance of the topic.

"Eh, no".

New member

Posts

Joined
Sat Apr 22, 2017 9:30 am

Post by drest341 » Tue Feb 23, 2021 4:07 pm

rgbrewer wrote:
Sat Aug 24, 2019 11:30 pm
There's actually several problems with this code... here are my revisions that are currently working properly.
https://pastebin.com/2fx4vxA3
It works perfect for me on OC3.0.3.1 - thanks

Any fool can write code that a computer can understand. Good programmers write code that humans can understand ~ Martin Fowler.


User avatar
New member

Posts

Joined
Fri Feb 21, 2014 10:47 pm
Location - Athens
Who is online

Users browsing this forum: No registered users and 11 guests