-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize computing dominant color and transparency for images by combining the two functions #381
Optimize computing dominant color and transparency for images by combining the two functions #381
Conversation
…or_has_transparency() functions into single function Updated tests and improved the images Introduced two new functions dominant_color_get_dominant_color() and dominant_color_has_transparency() that fetchs the date from image meta
…or_has_transparency() functions into single function Updated tests and improved the images Introduced two new functions dominant_color_get_dominant_color() and dominant_color_has_transparency() that fetchs the date from image meta
…or_has_transparency() functions into single function Updated tests and improved the images Introduced two new functions dominant_color_get_dominant_color() and dominant_color_has_transparency() that fetchs the date from image meta
$hex = dechex( imagecolorat( $shorted_image, 0, 0 ) ); | ||
|
||
if ( strlen( $hex ) < 6 ) { | ||
return new WP_Error( 'image_editor_dominant_color_error', __( 'Dominant color detection failed.', 'performance-lab' ) ); | ||
} | ||
return $hex; | ||
return dechex( imagecolorat( $shorted_image, 0, 0 ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this change a little more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are getting color with the shorten form #fff back from the underlining PHP code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it better to always return a 6 character hex here.
modules/images/dominant-color/class-dominant-color-image-editor-imagick.php
Show resolved
Hide resolved
Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pbearne I think the changes related to the issue look good for the most part, but this PR includes a bunch of additional changes which I think are out of scope as they do not relate to the underlying issue.
I think the only changes that are needed here are those in the load.php
file (plus related tests). What is the reasoning for modifying the implementation of the image classes here? That seems out of scope.
modules/images/dominant-color/class-dominant-color-image-editor-gd.php
Outdated
Show resolved
Hide resolved
…ing_up_image_editor
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
modules/images/dominant-color/class-dominant-color-image-editor-gd.php
Outdated
Show resolved
Hide resolved
|
||
if ( strlen( $hex ) < 6 ) { | ||
$rgb = imagecolorat( $shorted_image, 0, 0 ); | ||
$r = ( $rgb >> 16 ) & 0xFF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed up some changed to add some more unit test coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pbearne Pretty much LGTM now. The remaining comments are minor, would be great if you could address them.
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spacedmonkey Thanks for the quick iteration. LGTM! 🎉
…or_has_transparency() functions into single function
Updated tests and improved the images
Introduced two new functions dominant_color_get_dominant_color() and dominant_color_has_transparency() that fetchs the date from image meta
Summary
Fixes #
Relevant technical choices
Checklist
[Focus]
orInfrastructure
label.[Type]
label.no milestone
label.