repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
auth0/auth0-PHP
src/API/Helpers/InformationHeaders.php
InformationHeaders.Extend
public static function Extend(InformationHeaders $headers) { $new_headers = new InformationHeaders; $old_headers = $headers->get(); if (! empty( $old_headers['env'] ) && is_array( $old_headers['env'] )) { $new_headers->setEnvironmentData($old_headers['env']); } ...
php
public static function Extend(InformationHeaders $headers) { $new_headers = new InformationHeaders; $old_headers = $headers->get(); if (! empty( $old_headers['env'] ) && is_array( $old_headers['env'] )) { $new_headers->setEnvironmentData($old_headers['env']); } ...
[ "public", "static", "function", "Extend", "(", "InformationHeaders", "$", "headers", ")", "{", "$", "new_headers", "=", "new", "InformationHeaders", ";", "$", "old_headers", "=", "$", "headers", "->", "get", "(", ")", ";", "if", "(", "!", "empty", "(", "...
Extend an existing InformationHeaders object. Used in dependant modules to set a new SDK name and version but keep existing PHP SDK data. @param InformationHeaders $headers InformationHeaders object to extend. @return InformationHeaders
[ "Extend", "an", "existing", "InformationHeaders", "object", ".", "Used", "in", "dependant", "modules", "to", "set", "a", "new", "SDK", "name", "and", "version", "but", "keep", "existing", "PHP", "SDK", "data", "." ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/API/Helpers/InformationHeaders.php#L103-L115
auth0/auth0-PHP
src/API/Helpers/State/SessionStateHandler.php
SessionStateHandler.validate
public function validate($state) { $valid = $this->store->get(self::STATE_NAME) == $state; $this->store->delete(self::STATE_NAME); return $valid; }
php
public function validate($state) { $valid = $this->store->get(self::STATE_NAME) == $state; $this->store->delete(self::STATE_NAME); return $valid; }
[ "public", "function", "validate", "(", "$", "state", ")", "{", "$", "valid", "=", "$", "this", "->", "store", "->", "get", "(", "self", "::", "STATE_NAME", ")", "==", "$", "state", ";", "$", "this", "->", "store", "->", "delete", "(", "self", "::",...
Perform validation of the returned state with the previously generated state. @param string $state @return boolean
[ "Perform", "validation", "of", "the", "returned", "state", "with", "the", "previously", "generated", "state", "." ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/API/Helpers/State/SessionStateHandler.php#L67-L72
auth0/auth0-PHP
src/Auth0.php
Auth0.login
public function login($state = null, $connection = null, array $additionalParams = []) { $params = []; if ($this->audience) { $params['audience'] = $this->audience; } if ($this->scope) { $params['scope'] = $this->scope; } if ($state === null)...
php
public function login($state = null, $connection = null, array $additionalParams = []) { $params = []; if ($this->audience) { $params['audience'] = $this->audience; } if ($this->scope) { $params['scope'] = $this->scope; } if ($state === null)...
[ "public", "function", "login", "(", "$", "state", "=", "null", ",", "$", "connection", "=", "null", ",", "array", "$", "additionalParams", "=", "[", "]", ")", "{", "$", "params", "=", "[", "]", ";", "if", "(", "$", "this", "->", "audience", ")", ...
Redirect to the hosted login page for a specific client @param null $state - state value. @param null $connection - connection to use. @param array $additionalParams - additional, valid parameters. @return void @see \Auth0\SDK\API\Authentication::get_authorize_link() @see https://auth0.com/docs/ap...
[ "Redirect", "to", "the", "hosted", "login", "page", "for", "a", "specific", "client" ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Auth0.php#L412-L445
auth0/auth0-PHP
src/Auth0.php
Auth0.exchange
public function exchange() { $code = $this->getAuthorizationCode(); if (! $code) { return false; } $state = $this->getState(); if (! $this->stateHandler->validate($state)) { throw new CoreException('Invalid state'); } if ($this->user)...
php
public function exchange() { $code = $this->getAuthorizationCode(); if (! $code) { return false; } $state = $this->getState(); if (! $this->stateHandler->validate($state)) { throw new CoreException('Invalid state'); } if ($this->user)...
[ "public", "function", "exchange", "(", ")", "{", "$", "code", "=", "$", "this", "->", "getAuthorizationCode", "(", ")", ";", "if", "(", "!", "$", "code", ")", "{", "return", "false", ";", "}", "$", "state", "=", "$", "this", "->", "getState", "(", ...
Exchange authorization code for access, ID, and refresh tokens @throws CoreException If the state value is missing or invalid. @throws CoreException If there is already an active session. @throws ApiException If access token is missing from the response. @throws RequestException If HTTP request fails (e.g. access toke...
[ "Exchange", "authorization", "code", "for", "access", "ID", "and", "refresh", "tokens" ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Auth0.php#L527-L570
auth0/auth0-PHP
src/Auth0.php
Auth0.renewTokens
public function renewTokens() { if (! $this->accessToken) { throw new CoreException('Can\'t renew the access token if there isn\'t one valid'); } if (! $this->refreshToken) { throw new CoreException('Can\'t renew the access token if there isn\'t a refresh token avail...
php
public function renewTokens() { if (! $this->accessToken) { throw new CoreException('Can\'t renew the access token if there isn\'t one valid'); } if (! $this->refreshToken) { throw new CoreException('Can\'t renew the access token if there isn\'t a refresh token avail...
[ "public", "function", "renewTokens", "(", ")", "{", "if", "(", "!", "$", "this", "->", "accessToken", ")", "{", "throw", "new", "CoreException", "(", "'Can\\'t renew the access token if there isn\\'t one valid'", ")", ";", "}", "if", "(", "!", "$", "this", "->...
Renews the access token and ID token using an existing refresh token. Scope "offline_access" must be declared in order to obtain refresh token for later token renewal. @throws CoreException If the Auth0 object does not have access token and refresh token @throws ApiException If the Auth0 API did not renew access and I...
[ "Renews", "the", "access", "token", "and", "ID", "token", "using", "an", "existing", "refresh", "token", ".", "Scope", "offline_access", "must", "be", "declared", "in", "order", "to", "obtain", "refresh", "token", "for", "later", "token", "renewal", "." ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Auth0.php#L580-L598
auth0/auth0-PHP
src/Auth0.php
Auth0.setUser
public function setUser(array $user) { if (in_array('user', $this->persistantMap)) { $this->store->set('user', $user); } $this->user = $user; return $this; }
php
public function setUser(array $user) { if (in_array('user', $this->persistantMap)) { $this->store->set('user', $user); } $this->user = $user; return $this; }
[ "public", "function", "setUser", "(", "array", "$", "user", ")", "{", "if", "(", "in_array", "(", "'user'", ",", "$", "this", "->", "persistantMap", ")", ")", "{", "$", "this", "->", "store", "->", "set", "(", "'user'", ",", "$", "user", ")", ";", ...
Set the user property to a userinfo array and, if configured, persist @param array $user - userinfo from Auth0. @return $this
[ "Set", "the", "user", "property", "to", "a", "userinfo", "array", "and", "if", "configured", "persist" ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Auth0.php#L607-L615
auth0/auth0-PHP
src/Auth0.php
Auth0.setAccessToken
public function setAccessToken($accessToken) { if (in_array('access_token', $this->persistantMap)) { $this->store->set('access_token', $accessToken); } $this->accessToken = $accessToken; return $this; }
php
public function setAccessToken($accessToken) { if (in_array('access_token', $this->persistantMap)) { $this->store->set('access_token', $accessToken); } $this->accessToken = $accessToken; return $this; }
[ "public", "function", "setAccessToken", "(", "$", "accessToken", ")", "{", "if", "(", "in_array", "(", "'access_token'", ",", "$", "this", "->", "persistantMap", ")", ")", "{", "$", "this", "->", "store", "->", "set", "(", "'access_token'", ",", "$", "ac...
Sets and persists the access token. @param string $accessToken - access token returned from the code exchange. @return \Auth0\SDK\Auth0
[ "Sets", "and", "persists", "the", "access", "token", "." ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Auth0.php#L624-L632
auth0/auth0-PHP
src/Auth0.php
Auth0.setIdToken
public function setIdToken($idToken) { $jwtVerifier = new JWTVerifier([ 'valid_audiences' => ! empty($this->idTokenAud) ? $this->idTokenAud : [ $this->clientId ], 'supported_algs' => $this->idTokenAlg ? [ $this->idTokenAlg ] : [ 'HS256', 'RS256' ], 'authorized_is...
php
public function setIdToken($idToken) { $jwtVerifier = new JWTVerifier([ 'valid_audiences' => ! empty($this->idTokenAud) ? $this->idTokenAud : [ $this->clientId ], 'supported_algs' => $this->idTokenAlg ? [ $this->idTokenAlg ] : [ 'HS256', 'RS256' ], 'authorized_is...
[ "public", "function", "setIdToken", "(", "$", "idToken", ")", "{", "$", "jwtVerifier", "=", "new", "JWTVerifier", "(", "[", "'valid_audiences'", "=>", "!", "empty", "(", "$", "this", "->", "idTokenAud", ")", "?", "$", "this", "->", "idTokenAud", ":", "["...
Sets, validates, and persists the ID token. @param string $idToken - ID token returned from the code exchange. @return \Auth0\SDK\Auth0 @throws CoreException @throws Exception\InvalidTokenException
[ "Sets", "validates", "and", "persists", "the", "ID", "token", "." ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Auth0.php#L644-L662
auth0/auth0-PHP
src/Auth0.php
Auth0.setRefreshToken
public function setRefreshToken($refreshToken) { if (in_array('refresh_token', $this->persistantMap)) { $this->store->set('refresh_token', $refreshToken); } $this->refreshToken = $refreshToken; return $this; }
php
public function setRefreshToken($refreshToken) { if (in_array('refresh_token', $this->persistantMap)) { $this->store->set('refresh_token', $refreshToken); } $this->refreshToken = $refreshToken; return $this; }
[ "public", "function", "setRefreshToken", "(", "$", "refreshToken", ")", "{", "if", "(", "in_array", "(", "'refresh_token'", ",", "$", "this", "->", "persistantMap", ")", ")", "{", "$", "this", "->", "store", "->", "set", "(", "'refresh_token'", ",", "$", ...
Sets and persists the refresh token. @param string $refreshToken - refresh token returned from the code exchange. @return \Auth0\SDK\Auth0
[ "Sets", "and", "persists", "the", "refresh", "token", "." ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Auth0.php#L671-L679
auth0/auth0-PHP
src/Auth0.php
Auth0.getAuthorizationCode
protected function getAuthorizationCode() { $code = null; if ($this->responseMode === 'query' && isset($_GET['code'])) { $code = $_GET['code']; } else if ($this->responseMode === 'form_post' && isset($_POST['code'])) { $code = $_POST['code']; } return...
php
protected function getAuthorizationCode() { $code = null; if ($this->responseMode === 'query' && isset($_GET['code'])) { $code = $_GET['code']; } else if ($this->responseMode === 'form_post' && isset($_POST['code'])) { $code = $_POST['code']; } return...
[ "protected", "function", "getAuthorizationCode", "(", ")", "{", "$", "code", "=", "null", ";", "if", "(", "$", "this", "->", "responseMode", "===", "'query'", "&&", "isset", "(", "$", "_GET", "[", "'code'", "]", ")", ")", "{", "$", "code", "=", "$", ...
Get the authorization code from POST or GET, depending on response_mode @return string|null @see https://auth0.com/docs/api-auth/tutorials/authorization-code-grant
[ "Get", "the", "authorization", "code", "from", "POST", "or", "GET", "depending", "on", "response_mode" ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Auth0.php#L688-L698
auth0/auth0-PHP
src/Auth0.php
Auth0.getState
protected function getState() { $state = null; if ($this->responseMode === 'query' && isset($_GET['state'])) { $state = $_GET['state']; } else if ($this->responseMode === 'form_post' && isset($_POST['state'])) { $state = $_POST['state']; } return $sta...
php
protected function getState() { $state = null; if ($this->responseMode === 'query' && isset($_GET['state'])) { $state = $_GET['state']; } else if ($this->responseMode === 'form_post' && isset($_POST['state'])) { $state = $_POST['state']; } return $sta...
[ "protected", "function", "getState", "(", ")", "{", "$", "state", "=", "null", ";", "if", "(", "$", "this", "->", "responseMode", "===", "'query'", "&&", "isset", "(", "$", "_GET", "[", "'state'", "]", ")", ")", "{", "$", "state", "=", "$", "_GET",...
Get the state from POST or GET, depending on response_mode @return string|null @see https://auth0.com/docs/api-auth/tutorials/authorization-code-grant
[ "Get", "the", "state", "from", "POST", "or", "GET", "depending", "on", "response_mode" ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Auth0.php#L707-L717
auth0/auth0-PHP
src/Auth0.php
Auth0.logout
public function logout() { $this->deleteAllPersistentData(); $this->accessToken = null; $this->user = null; $this->idToken = null; $this->refreshToken = null; }
php
public function logout() { $this->deleteAllPersistentData(); $this->accessToken = null; $this->user = null; $this->idToken = null; $this->refreshToken = null; }
[ "public", "function", "logout", "(", ")", "{", "$", "this", "->", "deleteAllPersistentData", "(", ")", ";", "$", "this", "->", "accessToken", "=", "null", ";", "$", "this", "->", "user", "=", "null", ";", "$", "this", "->", "idToken", "=", "null", ";...
Delete any persistent data and clear out all stored properties @return void
[ "Delete", "any", "persistent", "data", "and", "clear", "out", "all", "stored", "properties" ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Auth0.php#L724-L731
auth0/auth0-PHP
src/API/Management/Users.php
Users.create
public function create(array $data) { if (empty($data['connection'])) { throw new \Exception('Missing required "connection" field.'); } if ('sms' === $data['connection'] && empty($data['phone_number'])) { // "phone_number" field is required for an sms connection. ...
php
public function create(array $data) { if (empty($data['connection'])) { throw new \Exception('Missing required "connection" field.'); } if ('sms' === $data['connection'] && empty($data['phone_number'])) { // "phone_number" field is required for an sms connection. ...
[ "public", "function", "create", "(", "array", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", "[", "'connection'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Missing required \"connection\" field.'", ")", ";", "}", "if", "...
Create a new User. Required scope: "create:users" @param array $data User create data: - "connection" name field is required and limited to sms, email, & DB connections. - "phone_number" field is required by sms connections. - "email" field is required by email and DB connections. - "password" field is required by DB ...
[ "Create", "a", "new", "User", ".", "Required", "scope", ":", "create", ":", "users" ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/API/Management/Users.php#L74-L99
auth0/auth0-PHP
src/API/Management/Users.php
Users.getAll
public function getAll(array $params = [], $fields = null, $include_fields = null, $page = null, $per_page = null) { $params = is_array($params) ? $params : []; // Fields to include/exclude. if (! isset($params['fields']) && null !== $fields) { $params['fields'] = $fields; ...
php
public function getAll(array $params = [], $fields = null, $include_fields = null, $page = null, $per_page = null) { $params = is_array($params) ? $params : []; // Fields to include/exclude. if (! isset($params['fields']) && null !== $fields) { $params['fields'] = $fields; ...
[ "public", "function", "getAll", "(", "array", "$", "params", "=", "[", "]", ",", "$", "fields", "=", "null", ",", "$", "include_fields", "=", "null", ",", "$", "page", "=", "null", ",", "$", "per_page", "=", "null", ")", "{", "$", "params", "=", ...
Search all Users. Required scopes: - "read:users" - For any call to this endpoint. - "read:user_idp_tokens" - To retrieve the "access_token" field for logged-in identities. @param array $params Search parameters to send: - "fields", "include_fields", "page", and "per_page" keys here will override t...
[ "Search", "all", "Users", ".", "Required", "scopes", ":", "-", "read", ":", "users", "-", "For", "any", "call", "to", "this", "endpoint", ".", "-", "read", ":", "user_idp_tokens", "-", "To", "retrieve", "the", "access_token", "field", "for", "logged", "-...
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/API/Management/Users.php#L124-L156
auth0/auth0-PHP
src/API/Management/Users.php
Users.linkAccount
public function linkAccount($user_id, array $data) { return $this->apiClient->method('post') ->addPath('users', $user_id) ->addPath('identities') ->withBody(json_encode($data)) ->call(); }
php
public function linkAccount($user_id, array $data) { return $this->apiClient->method('post') ->addPath('users', $user_id) ->addPath('identities') ->withBody(json_encode($data)) ->call(); }
[ "public", "function", "linkAccount", "(", "$", "user_id", ",", "array", "$", "data", ")", "{", "return", "$", "this", "->", "apiClient", "->", "method", "(", "'post'", ")", "->", "addPath", "(", "'users'", ",", "$", "user_id", ")", "->", "addPath", "("...
Link one user identity to another. Required scope: "update:users" @param string $user_id User ID of the primary account. @param array $data An array with the following fields: - "provider" - Secondary account provider. - "user_id" - Secondary account user ID. - "connection_id" - Secondary account Connection ID (op...
[ "Link", "one", "user", "identity", "to", "another", ".", "Required", "scope", ":", "update", ":", "users" ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/API/Management/Users.php#L193-L200
auth0/auth0-PHP
src/API/Management/Users.php
Users.unlinkAccount
public function unlinkAccount($user_id, $provider, $identity_id) { return $this->apiClient->method('delete') ->addPath('users', $user_id) ->addPath('identities', $provider) ->addPathVariable($identity_id) ->call(); }
php
public function unlinkAccount($user_id, $provider, $identity_id) { return $this->apiClient->method('delete') ->addPath('users', $user_id) ->addPath('identities', $provider) ->addPathVariable($identity_id) ->call(); }
[ "public", "function", "unlinkAccount", "(", "$", "user_id", ",", "$", "provider", ",", "$", "identity_id", ")", "{", "return", "$", "this", "->", "apiClient", "->", "method", "(", "'delete'", ")", "->", "addPath", "(", "'users'", ",", "$", "user_id", ")"...
Unlink an identity from the target user. Required scope: "update:users" @param string $user_id User ID to unlink. @param string $provider Identity provider of the secondary linked account. @param string $identity_id The unique identifier of the secondary linked account. @return mixed|string @throws \Exception...
[ "Unlink", "an", "identity", "from", "the", "target", "user", ".", "Required", "scope", ":", "update", ":", "users" ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/API/Management/Users.php#L216-L223
auth0/auth0-PHP
src/API/Management/Users.php
Users.deleteMultifactorProvider
public function deleteMultifactorProvider($user_id, $mfa_provider) { return $this->apiClient->method('delete') ->addPath('users', $user_id) ->addPath('multifactor', $mfa_provider) ->call(); }
php
public function deleteMultifactorProvider($user_id, $mfa_provider) { return $this->apiClient->method('delete') ->addPath('users', $user_id) ->addPath('multifactor', $mfa_provider) ->call(); }
[ "public", "function", "deleteMultifactorProvider", "(", "$", "user_id", ",", "$", "mfa_provider", ")", "{", "return", "$", "this", "->", "apiClient", "->", "method", "(", "'delete'", ")", "->", "addPath", "(", "'users'", ",", "$", "user_id", ")", "->", "ad...
Delete the multifactor provider settings for a particular user. This will force user to re-configure the multifactor provider. Required scope: "update:users" @param string $user_id User ID with the multifactor provider to delete. @param string $mfa_provider Multifactor provider to delete. @return mixed|string @...
[ "Delete", "the", "multifactor", "provider", "settings", "for", "a", "particular", "user", ".", "This", "will", "force", "user", "to", "re", "-", "configure", "the", "multifactor", "provider", ".", "Required", "scope", ":", "update", ":", "users" ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/API/Management/Users.php#L237-L243
auth0/auth0-PHP
src/Helpers/JWKFetcher.php
JWKFetcher.convertCertToPem
protected function convertCertToPem($cert) { $output = '-----BEGIN CERTIFICATE-----'.PHP_EOL; $output .= chunk_split($cert, 64, PHP_EOL); $output .= '-----END CERTIFICATE-----'.PHP_EOL; return $output; }
php
protected function convertCertToPem($cert) { $output = '-----BEGIN CERTIFICATE-----'.PHP_EOL; $output .= chunk_split($cert, 64, PHP_EOL); $output .= '-----END CERTIFICATE-----'.PHP_EOL; return $output; }
[ "protected", "function", "convertCertToPem", "(", "$", "cert", ")", "{", "$", "output", "=", "'-----BEGIN CERTIFICATE-----'", ".", "PHP_EOL", ";", "$", "output", ".=", "chunk_split", "(", "$", "cert", ",", "64", ",", "PHP_EOL", ")", ";", "$", "output", ".=...
Convert a certificate to PEM format. @param string $cert X509 certificate to convert to PEM format. @return string
[ "Convert", "a", "certificate", "to", "PEM", "format", "." ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Helpers/JWKFetcher.php#L57-L63
auth0/auth0-PHP
src/Helpers/JWKFetcher.php
JWKFetcher.requestJwkX5c
public function requestJwkX5c($jwks_url, $kid = null) { $cache_key = $jwks_url.'|'.$kid; $x5c = $this->cache->get($cache_key); if (! is_null($x5c)) { return $x5c; } $jwks = $this->requestJwks($jwks_url); $jwk = $this->findJwk($jwks, $kid); if (...
php
public function requestJwkX5c($jwks_url, $kid = null) { $cache_key = $jwks_url.'|'.$kid; $x5c = $this->cache->get($cache_key); if (! is_null($x5c)) { return $x5c; } $jwks = $this->requestJwks($jwks_url); $jwk = $this->findJwk($jwks, $kid); if (...
[ "public", "function", "requestJwkX5c", "(", "$", "jwks_url", ",", "$", "kid", "=", "null", ")", "{", "$", "cache_key", "=", "$", "jwks_url", ".", "'|'", ".", "$", "kid", ";", "$", "x5c", "=", "$", "this", "->", "cache", "->", "get", "(", "$", "ca...
Fetch x509 cert for RS256 token decoding. @param string $jwks_url URL to the JWKS. @param string|null $kid Key ID to use; returns first JWK if $kid is null or empty. @return string|null - Null if an x5c key could not be found for a key ID or if the JWKS is empty/invalid.
[ "Fetch", "x509", "cert", "for", "RS256", "token", "decoding", "." ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Helpers/JWKFetcher.php#L73-L92
auth0/auth0-PHP
src/Helpers/JWKFetcher.php
JWKFetcher.findJwk
private function findJwk(array $jwks, $kid = null) { if ($this->subArrayHasEmptyFirstItem($jwks, 'keys')) { return null; } if (! $kid) { return $jwks['keys'][0]; } foreach ($jwks['keys'] as $key) { if (isset($key['kid']) && $key['kid'] ==...
php
private function findJwk(array $jwks, $kid = null) { if ($this->subArrayHasEmptyFirstItem($jwks, 'keys')) { return null; } if (! $kid) { return $jwks['keys'][0]; } foreach ($jwks['keys'] as $key) { if (isset($key['kid']) && $key['kid'] ==...
[ "private", "function", "findJwk", "(", "array", "$", "jwks", ",", "$", "kid", "=", "null", ")", "{", "if", "(", "$", "this", "->", "subArrayHasEmptyFirstItem", "(", "$", "jwks", ",", "'keys'", ")", ")", "{", "return", "null", ";", "}", "if", "(", "...
Get a JWK from a JWKS using a key ID, if provided. @param array $jwks JWKS to parse. @param null|string $kid Key ID to return; returns first JWK if $kid is null or empty. @return array|null Null if the keys array is empty or if the key ID is not found. @codeCoverageIgnore
[ "Get", "a", "JWK", "from", "a", "JWKS", "using", "a", "key", "ID", "if", "provided", "." ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Helpers/JWKFetcher.php#L126-L143
auth0/auth0-PHP
src/Helpers/JWKFetcher.php
JWKFetcher.fetchKeys
public function fetchKeys($iss) { $url = "{$iss}.well-known/jwks.json"; if (($secret = $this->cache->get($url)) === null) { $secret = []; $request = new RequestBuilder([ 'domain' => $iss, 'basePath' => '.well-known/jwks.json', ...
php
public function fetchKeys($iss) { $url = "{$iss}.well-known/jwks.json"; if (($secret = $this->cache->get($url)) === null) { $secret = []; $request = new RequestBuilder([ 'domain' => $iss, 'basePath' => '.well-known/jwks.json', ...
[ "public", "function", "fetchKeys", "(", "$", "iss", ")", "{", "$", "url", "=", "\"{$iss}.well-known/jwks.json\"", ";", "if", "(", "(", "$", "secret", "=", "$", "this", "->", "cache", "->", "get", "(", "$", "url", ")", ")", "===", "null", ")", "{", ...
Appends the default JWKS path to a token issuer to return all keys from a JWKS. @deprecated 5.4.0, use requestJwkX5c instead. @param string $iss @return array|mixed|null @throws \Exception @codeCoverageIgnore
[ "Appends", "the", "default", "JWKS", "path", "to", "a", "token", "issuer", "to", "return", "all", "keys", "from", "a", "JWKS", "." ]
train
https://github.com/auth0/auth0-PHP/blob/a5d0d173885c13cb5ce1758de33df68a0d539ffd/src/Helpers/JWKFetcher.php#L178-L201
kosinix/grafika
src/Grafika/Color.php
Color.getRgba
public function getRgba(){ $rgba = $this->hexToRgb( $this->hexString ); $rgba[] = $this->alpha; return $rgba; }
php
public function getRgba(){ $rgba = $this->hexToRgb( $this->hexString ); $rgba[] = $this->alpha; return $rgba; }
[ "public", "function", "getRgba", "(", ")", "{", "$", "rgba", "=", "$", "this", "->", "hexToRgb", "(", "$", "this", "->", "hexString", ")", ";", "$", "rgba", "[", "]", "=", "$", "this", "->", "alpha", ";", "return", "$", "rgba", ";", "}" ]
Get RGBA array @return array Contains array($r, $g, $b, $a)
[ "Get", "RGBA", "array" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Color.php#L45-L49
kosinix/grafika
src/Grafika/Color.php
Color.hexToRgb
public function hexToRgb( $hex ) { $hex = ltrim($hex, '#'); // Remove # if(strlen($hex) == 3) { $r = hexdec(substr($hex,0,1).substr($hex,0,1)); $g = hexdec(substr($hex,1,1).substr($hex,1,1)); $b = hexdec(substr($hex,2,1).substr($hex,2,1)); } else { ...
php
public function hexToRgb( $hex ) { $hex = ltrim($hex, '#'); // Remove # if(strlen($hex) == 3) { $r = hexdec(substr($hex,0,1).substr($hex,0,1)); $g = hexdec(substr($hex,1,1).substr($hex,1,1)); $b = hexdec(substr($hex,2,1).substr($hex,2,1)); } else { ...
[ "public", "function", "hexToRgb", "(", "$", "hex", ")", "{", "$", "hex", "=", "ltrim", "(", "$", "hex", ",", "'#'", ")", ";", "// Remove #", "if", "(", "strlen", "(", "$", "hex", ")", "==", "3", ")", "{", "$", "r", "=", "hexdec", "(", "substr",...
Convert hex string to RGB @param string $hex Hex string. Possible values: #ffffff, #fff, fff @return array Contains (RGB) values red, green and blue
[ "Convert", "hex", "string", "to", "RGB" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Color.php#L56-L69
kosinix/grafika
src/Grafika/Gd/Helper/GifHelper.php
GifHelper.open
public function open($imageFile){ $fp = fopen( $imageFile, 'rb'); // Binary read if($fp === false ) { throw new \Exception(sprintf('Error loading file: "%s".', $imageFile)); } $size = filesize( $imageFile ); $bytes = fread($fp, $size); $bytes = unpack('H*', ...
php
public function open($imageFile){ $fp = fopen( $imageFile, 'rb'); // Binary read if($fp === false ) { throw new \Exception(sprintf('Error loading file: "%s".', $imageFile)); } $size = filesize( $imageFile ); $bytes = fread($fp, $size); $bytes = unpack('H*', ...
[ "public", "function", "open", "(", "$", "imageFile", ")", "{", "$", "fp", "=", "fopen", "(", "$", "imageFile", ",", "'rb'", ")", ";", "// Binary read", "if", "(", "$", "fp", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf",...
@param $imageFile @return GifByteStream @throws \Exception
[ "@param", "$imageFile" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Helper/GifHelper.php#L12-L26
kosinix/grafika
src/Grafika/Gd/Helper/GifHelper.php
GifHelper.isAnimated
public function isAnimated($bytes){ $bytes->setPosition(13); $lastPos = $bytes->getPosition(); $gceCount = 0; while (($lastPos = $bytes->find('21f904', $lastPos))!== false) { $gceCount++; if($gceCount>1){ return true; } } ...
php
public function isAnimated($bytes){ $bytes->setPosition(13); $lastPos = $bytes->getPosition(); $gceCount = 0; while (($lastPos = $bytes->find('21f904', $lastPos))!== false) { $gceCount++; if($gceCount>1){ return true; } } ...
[ "public", "function", "isAnimated", "(", "$", "bytes", ")", "{", "$", "bytes", "->", "setPosition", "(", "13", ")", ";", "$", "lastPos", "=", "$", "bytes", "->", "getPosition", "(", ")", ";", "$", "gceCount", "=", "0", ";", "while", "(", "(", "$", ...
@param GifByteStream $bytes @return bool
[ "@param", "GifByteStream", "$bytes" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Helper/GifHelper.php#L45-L57
kosinix/grafika
src/Grafika/Gd/Helper/GifHelper.php
GifHelper.encode
public function encode($data){ $hex = ''; // header block $hex .= $this->_fixSize($this->_asciiToHex($data['signature']),3); $hex .= $this->_fixSize($this->_asciiToHex($data['version']),3); // logical screen descriptor block $hex .= $this->_switchEndian($this->_fixSize(d...
php
public function encode($data){ $hex = ''; // header block $hex .= $this->_fixSize($this->_asciiToHex($data['signature']),3); $hex .= $this->_fixSize($this->_asciiToHex($data['version']),3); // logical screen descriptor block $hex .= $this->_switchEndian($this->_fixSize(d...
[ "public", "function", "encode", "(", "$", "data", ")", "{", "$", "hex", "=", "''", ";", "// header block", "$", "hex", ".=", "$", "this", "->", "_fixSize", "(", "$", "this", "->", "_asciiToHex", "(", "$", "data", "[", "'signature'", "]", ")", ",", ...
Encode data into GIF hex string. @param array $data The array returned by decode. @return string Hex string of GIF
[ "Encode", "data", "into", "GIF", "hex", "string", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Helper/GifHelper.php#L66-L138
kosinix/grafika
src/Grafika/Gd/Helper/GifHelper.php
GifHelper.decode
public function decode($bytes){ $bytes->setPosition(0); $blocks = $this->decodeToBlocks($bytes); return $this->expandBlocks($blocks); }
php
public function decode($bytes){ $bytes->setPosition(0); $blocks = $this->decodeToBlocks($bytes); return $this->expandBlocks($blocks); }
[ "public", "function", "decode", "(", "$", "bytes", ")", "{", "$", "bytes", "->", "setPosition", "(", "0", ")", ";", "$", "blocks", "=", "$", "this", "->", "decodeToBlocks", "(", "$", "bytes", ")", ";", "return", "$", "this", "->", "expandBlocks", "("...
Decode GIF into array of data for easy use in PHP userland. @param GifByteStream $bytes Decode byte stream into array of GIF blocks. @return array Array containing GIF data @throws \Exception
[ "Decode", "GIF", "into", "array", "of", "data", "for", "easy", "use", "in", "PHP", "userland", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Helper/GifHelper.php#L149-L154
kosinix/grafika
src/Grafika/Gd/Helper/GifHelper.php
GifHelper.decodeToBlocks
public function decodeToBlocks($bytes){ $bytes->setPosition(0); $blocks = array(); // Header block $blocks['header'] = $bytes->bite(6); // Logical screen descriptor block $part = $bytes->bite(2); // canvass w $hex = $part; $part = $bytes->bite(2); // can...
php
public function decodeToBlocks($bytes){ $bytes->setPosition(0); $blocks = array(); // Header block $blocks['header'] = $bytes->bite(6); // Logical screen descriptor block $part = $bytes->bite(2); // canvass w $hex = $part; $part = $bytes->bite(2); // can...
[ "public", "function", "decodeToBlocks", "(", "$", "bytes", ")", "{", "$", "bytes", "->", "setPosition", "(", "0", ")", ";", "$", "blocks", "=", "array", "(", ")", ";", "// Header block", "$", "blocks", "[", "'header'", "]", "=", "$", "bytes", "->", "...
Decompose GIF into its block components. The GIF blocks are in the order that they appear in the byte stream. @param GifByteStream $bytes @return array @throws \Exception
[ "Decompose", "GIF", "into", "its", "block", "components", ".", "The", "GIF", "blocks", "are", "in", "the", "order", "that", "they", "appear", "in", "the", "byte", "stream", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Helper/GifHelper.php#L164-L332
kosinix/grafika
src/Grafika/Gd/Helper/GifHelper.php
GifHelper.expandBlocks
public function expandBlocks($blocks){ $decoded = array(); foreach($blocks as $blockName=>$block){ $bytes = new GifByteStream($block); if(false !== strpos($blockName, 'header')){ $part = $bytes->bite(3); $decoded['signature'] = $this->_hexToAscii(...
php
public function expandBlocks($blocks){ $decoded = array(); foreach($blocks as $blockName=>$block){ $bytes = new GifByteStream($block); if(false !== strpos($blockName, 'header')){ $part = $bytes->bite(3); $decoded['signature'] = $this->_hexToAscii(...
[ "public", "function", "expandBlocks", "(", "$", "blocks", ")", "{", "$", "decoded", "=", "array", "(", ")", ";", "foreach", "(", "$", "blocks", "as", "$", "blockName", "=>", "$", "block", ")", "{", "$", "bytes", "=", "new", "GifByteStream", "(", "$",...
Expand GIF blocks into useful info. @param array $blocks Accepts the array returned by decodeToBlocks @return array
[ "Expand", "GIF", "blocks", "into", "useful", "info", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Helper/GifHelper.php#L341-L446
kosinix/grafika
src/Grafika/Gd/Helper/GifHelper.php
GifHelper.splitFrames
public function splitFrames($blocks){ $images = array(); if (isset($blocks['frames'])){ foreach($blocks['frames'] as $a=>$unused){ $images[$a] = $blocks; unset($images[$a]['frames']); // remove all frames. foreach($blocks['frames'] as $b=>$fram...
php
public function splitFrames($blocks){ $images = array(); if (isset($blocks['frames'])){ foreach($blocks['frames'] as $a=>$unused){ $images[$a] = $blocks; unset($images[$a]['frames']); // remove all frames. foreach($blocks['frames'] as $b=>$fram...
[ "public", "function", "splitFrames", "(", "$", "blocks", ")", "{", "$", "images", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "blocks", "[", "'frames'", "]", ")", ")", "{", "foreach", "(", "$", "blocks", "[", "'frames'", "]", "as", ...
@param array $blocks The array returned by decode. @return array Array of images each containing 1 of each frames of the original image.
[ "@param", "array", "$blocks", "The", "array", "returned", "by", "decode", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Helper/GifHelper.php#L453-L468
kosinix/grafika
src/Grafika/Gd/Helper/GifHelper.php
GifHelper.resize
public function resize($blocks, $newW, $newH){ $images = $this->splitFrames($blocks); // Loop on individual images and resize them using Gd $firstFrameGd = null; foreach($images as $imageIndex=>$image){ $hex = $this->encode($image); $binaryRaw = pack('H*', $hex);...
php
public function resize($blocks, $newW, $newH){ $images = $this->splitFrames($blocks); // Loop on individual images and resize them using Gd $firstFrameGd = null; foreach($images as $imageIndex=>$image){ $hex = $this->encode($image); $binaryRaw = pack('H*', $hex);...
[ "public", "function", "resize", "(", "$", "blocks", ",", "$", "newW", ",", "$", "newH", ")", "{", "$", "images", "=", "$", "this", "->", "splitFrames", "(", "$", "blocks", ")", ";", "// Loop on individual images and resize them using Gd", "$", "firstFrameGd", ...
@param $blocks @param $newW @param $newH @return array $blocks
[ "@param", "$blocks", "@param", "$newW", "@param", "$newH" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Helper/GifHelper.php#L477-L547
kosinix/grafika
src/Grafika/Gd/Helper/GifHelper.php
GifHelper._asciiToHex
private function _asciiToHex($asciiString){ $chars = str_split($asciiString, 1); $string = ''; foreach($chars as $char){ $string .= dechex(ord($char)); } return $string; }
php
private function _asciiToHex($asciiString){ $chars = str_split($asciiString, 1); $string = ''; foreach($chars as $char){ $string .= dechex(ord($char)); } return $string; }
[ "private", "function", "_asciiToHex", "(", "$", "asciiString", ")", "{", "$", "chars", "=", "str_split", "(", "$", "asciiString", ",", "1", ")", ";", "$", "string", "=", "''", ";", "foreach", "(", "$", "chars", "as", "$", "char", ")", "{", "$", "st...
@param $asciiString @return string
[ "@param", "$asciiString" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Helper/GifHelper.php#L554-L561
kosinix/grafika
src/Grafika/Gd/Helper/GifHelper.php
GifHelper._hexToAscii
private function _hexToAscii($hexString){ $bytes = str_split($hexString, 2); $string = ''; foreach($bytes as $byte){ $string .= chr(hexdec($byte)); // convert hex to dec to ascii character. See http://www.ascii.cl/ } return $string; }
php
private function _hexToAscii($hexString){ $bytes = str_split($hexString, 2); $string = ''; foreach($bytes as $byte){ $string .= chr(hexdec($byte)); // convert hex to dec to ascii character. See http://www.ascii.cl/ } return $string; }
[ "private", "function", "_hexToAscii", "(", "$", "hexString", ")", "{", "$", "bytes", "=", "str_split", "(", "$", "hexString", ",", "2", ")", ";", "$", "string", "=", "''", ";", "foreach", "(", "$", "bytes", "as", "$", "byte", ")", "{", "$", "string...
@param $hexString @return string
[ "@param", "$hexString" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Helper/GifHelper.php#L568-L575
kosinix/grafika
src/Grafika/Gd/Filter/Sobel.php
Sobel.apply
public function apply($image) { // Localize vars $width = $image->getWidth(); $height = $image->getHeight(); $old = $image->getCore(); $pixels = array(); $new = imagecreatetruecolor($width, $height); for ($y = 0; $y < $height; $y++) { for...
php
public function apply($image) { // Localize vars $width = $image->getWidth(); $height = $image->getHeight(); $old = $image->getCore(); $pixels = array(); $new = imagecreatetruecolor($width, $height); for ($y = 0; $y < $height; $y++) { for...
[ "public", "function", "apply", "(", "$", "image", ")", "{", "// Localize vars", "$", "width", "=", "$", "image", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "image", "->", "getHeight", "(", ")", ";", "$", "old", "=", "$", "image", "->...
@param Image $image @return Image
[ "@param", "Image", "$image" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Filter/Sobel.php#L20-L102
kosinix/grafika
src/Grafika/Gd/Filter/Sharpen.php
Sharpen.apply
public function apply( $image ) { $amount = $this->amount; // build matrix $min = $amount >= 10 ? $amount * -0.01 : 0; $max = $amount * -0.025; $abs = ((4 * $min + 4 * $max) * -1) + 1; $div = 1; $matrix = array( array($min, $max, $min), arr...
php
public function apply( $image ) { $amount = $this->amount; // build matrix $min = $amount >= 10 ? $amount * -0.01 : 0; $max = $amount * -0.025; $abs = ((4 * $min + 4 * $max) * -1) + 1; $div = 1; $matrix = array( array($min, $max, $min), arr...
[ "public", "function", "apply", "(", "$", "image", ")", "{", "$", "amount", "=", "$", "this", "->", "amount", ";", "// build matrix", "$", "min", "=", "$", "amount", ">=", "10", "?", "$", "amount", "*", "-", "0.01", ":", "0", ";", "$", "max", "=",...
@param Image $image @return Image
[ "@param", "Image", "$image" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Filter/Sharpen.php#L32-L47
kosinix/grafika
src/Grafika/Gd/Filter/Colorize.php
Colorize.apply
public function apply( $image ) { imagefilter($image->getCore(), IMG_FILTER_COLORIZE, $this->red, $this->green, $this->blue); return $image; }
php
public function apply( $image ) { imagefilter($image->getCore(), IMG_FILTER_COLORIZE, $this->red, $this->green, $this->blue); return $image; }
[ "public", "function", "apply", "(", "$", "image", ")", "{", "imagefilter", "(", "$", "image", "->", "getCore", "(", ")", ",", "IMG_FILTER_COLORIZE", ",", "$", "this", "->", "red", ",", "$", "this", "->", "green", ",", "$", "this", "->", "blue", ")", ...
@param Image $image @return Image
[ "@param", "Image", "$image" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Filter/Colorize.php#L44-L48
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.apply
public function apply(&$image, $filter) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $image = $filter->apply($image); return $this; }
php
public function apply(&$image, $filter) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $image = $filter->apply($image); return $this; }
[ "public", "function", "apply", "(", "&", "$", "image", ",", "$", "filter", ")", "{", "if", "(", "$", "image", "->", "isAnimated", "(", ")", ")", "{", "// Ignore animated GIF for now", "return", "$", "this", ";", "}", "$", "image", "=", "$", "filter", ...
Apply a filter to the image. See Filters section for a list of available filters. @param Image $image @param FilterInterface $filter @return Editor
[ "Apply", "a", "filter", "to", "the", "image", ".", "See", "Filters", "section", "for", "a", "list", "of", "available", "filters", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L30-L40
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.blend
public function blend(&$image1, $image2, $type='normal', $opacity = 1.0, $position = 'top-left', $offsetX = 0, $offsetY = 0 ){ // Turn into position object $position = new Position($position, $offsetX, $offsetY); // Position is for $image2. $image1 is canvas. list($offsetX, $offsetY) =...
php
public function blend(&$image1, $image2, $type='normal', $opacity = 1.0, $position = 'top-left', $offsetX = 0, $offsetY = 0 ){ // Turn into position object $position = new Position($position, $offsetX, $offsetY); // Position is for $image2. $image1 is canvas. list($offsetX, $offsetY) =...
[ "public", "function", "blend", "(", "&", "$", "image1", ",", "$", "image2", ",", "$", "type", "=", "'normal'", ",", "$", "opacity", "=", "1.0", ",", "$", "position", "=", "'top-left'", ",", "$", "offsetX", "=", "0", ",", "$", "offsetY", "=", "0", ...
Blend two images together with the first image as the base and the second image on top. Supports several blend modes. @param Image $image1 The base image. @param Image $image2 The image placed on top of the base image. @param string $type The blend mode. Can be: normal, multiply, overlay or screen. @param float $opaci...
[ "Blend", "two", "images", "together", "with", "the", "first", "image", "as", "the", "base", "and", "the", "second", "image", "on", "top", ".", "Supports", "several", "blend", "modes", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L56-L107
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.compare
public function compare($image1, $image2) { if (is_string($image1)) { // If string passed, turn it into a Image object $image1 = Image::createFromFile($image1); $this->flatten( $image1 ); } if (is_string($image2)) { // If string passed, turn it into a Image object ...
php
public function compare($image1, $image2) { if (is_string($image1)) { // If string passed, turn it into a Image object $image1 = Image::createFromFile($image1); $this->flatten( $image1 ); } if (is_string($image2)) { // If string passed, turn it into a Image object ...
[ "public", "function", "compare", "(", "$", "image1", ",", "$", "image2", ")", "{", "if", "(", "is_string", "(", "$", "image1", ")", ")", "{", "// If string passed, turn it into a Image object", "$", "image1", "=", "Image", "::", "createFromFile", "(", "$", "...
Compare two images and returns a hamming distance. A value of 0 indicates a likely similar picture. A value between 1 and 10 is potentially a variation. A value greater than 10 is likely a different image. @param ImageInterface|string $image1 @param ImageInterface|string $image2 @return int Hamming distance. Note: Th...
[ "Compare", "two", "images", "and", "returns", "a", "hamming", "distance", ".", "A", "value", "of", "0", "indicates", "a", "likely", "similar", "picture", ".", "A", "value", "between", "1", "and", "10", "is", "potentially", "a", "variation", ".", "A", "va...
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L118-L146
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.crop
public function crop(&$image, $cropWidth, $cropHeight, $position = 'center', $offsetX = 0, $offsetY = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } if ( 'smart' === $position ) { // Smart crop list( $x, $y ) = $this->_smartCrop( $im...
php
public function crop(&$image, $cropWidth, $cropHeight, $position = 'center', $offsetX = 0, $offsetY = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } if ( 'smart' === $position ) { // Smart crop list( $x, $y ) = $this->_smartCrop( $im...
[ "public", "function", "crop", "(", "&", "$", "image", ",", "$", "cropWidth", ",", "$", "cropHeight", ",", "$", "position", "=", "'center'", ",", "$", "offsetX", "=", "0", ",", "$", "offsetY", "=", "0", ")", "{", "if", "(", "$", "image", "->", "is...
Crop the image to the given dimension and position. @param Image $image @param int $cropWidth Crop width in pixels. @param int $cropHeight Crop Height in pixels. @param string $position The crop position. Possible values top-left, top-center, top-right, center-left, center, center-right, bottom-left, bottom-center, bo...
[ "Crop", "the", "image", "to", "the", "given", "dimension", "and", "position", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L161-L182
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.draw
public function draw(&$image, $drawingObject) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $image = $drawingObject->draw($image); return $this; }
php
public function draw(&$image, $drawingObject) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $image = $drawingObject->draw($image); return $this; }
[ "public", "function", "draw", "(", "&", "$", "image", ",", "$", "drawingObject", ")", "{", "if", "(", "$", "image", "->", "isAnimated", "(", ")", ")", "{", "// Ignore animated GIF for now", "return", "$", "this", ";", "}", "$", "image", "=", "$", "draw...
Draw a DrawingObject on the image. See Drawing Objects section. @param Image $image @param DrawingObjectInterface $drawingObject @return $this
[ "Draw", "a", "DrawingObject", "on", "the", "image", ".", "See", "Drawing", "Objects", "section", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L192-L202
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.equal
public function equal($image1, $image2) { if (is_string($image1)) { // If string passed, turn it into a Image object $image1 = Image::createFromFile($image1); $this->flatten( $image1 ); } if (is_string($image2)) { // If string passed, turn it into a Image object ...
php
public function equal($image1, $image2) { if (is_string($image1)) { // If string passed, turn it into a Image object $image1 = Image::createFromFile($image1); $this->flatten( $image1 ); } if (is_string($image2)) { // If string passed, turn it into a Image object ...
[ "public", "function", "equal", "(", "$", "image1", ",", "$", "image2", ")", "{", "if", "(", "is_string", "(", "$", "image1", ")", ")", "{", "// If string passed, turn it into a Image object", "$", "image1", "=", "Image", "::", "createFromFile", "(", "$", "im...
Compare if two images are equal. It will compare if the two images are of the same width and height. If the dimensions differ, it will return false. If the dimensions are equal, it will loop through each pixels. If one of the pixel don't match, it will return false. The pixels are compared using their RGB (Red, Green, ...
[ "Compare", "if", "two", "images", "are", "equal", ".", "It", "will", "compare", "if", "the", "two", "images", "are", "of", "the", "same", "width", "and", "height", ".", "If", "the", "dimensions", "differ", "it", "will", "return", "false", ".", "If", "t...
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L213-L260
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.fill
public function fill(&$image, $color, $x = 0, $y = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $target = $image->getCore()->getImagePixelColor($x, $y); $image->getCore()->floodfillPaintImage($color->getHexString(), 1, $target, $x, $y,...
php
public function fill(&$image, $color, $x = 0, $y = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $target = $image->getCore()->getImagePixelColor($x, $y); $image->getCore()->floodfillPaintImage($color->getHexString(), 1, $target, $x, $y,...
[ "public", "function", "fill", "(", "&", "$", "image", ",", "$", "color", ",", "$", "x", "=", "0", ",", "$", "y", "=", "0", ")", "{", "if", "(", "$", "image", "->", "isAnimated", "(", ")", ")", "{", "// Ignore animated GIF for now", "return", "$", ...
Fill entire image with color. @param Image $image @param Color $color Color object @param int $x X-coordinate of start point @param int $y Y-coordinate of start point @return self
[ "Fill", "entire", "image", "with", "color", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L272-L283
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.flatten
public function flatten(&$image){ if($image->isAnimated()){ $imagick = $image->getCore()->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); $image = new Image( $imagick, $image->getImageFile(), $image->getWidth(), $image->get...
php
public function flatten(&$image){ if($image->isAnimated()){ $imagick = $image->getCore()->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); $image = new Image( $imagick, $image->getImageFile(), $image->getWidth(), $image->get...
[ "public", "function", "flatten", "(", "&", "$", "image", ")", "{", "if", "(", "$", "image", "->", "isAnimated", "(", ")", ")", "{", "$", "imagick", "=", "$", "image", "->", "getCore", "(", ")", "->", "mergeImageLayers", "(", "\\", "Imagick", "::", ...
Flatten if animated GIF. Do nothing otherwise. @param Image $image @return self
[ "Flatten", "if", "animated", "GIF", ".", "Do", "nothing", "otherwise", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L292-L306
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.flip
public function flip(&$image, $mode){ if ($mode === 'h') { $image->getCore()->flopImage(); } else if ($mode === 'v') { $image->getCore()->flipImage(); } else { throw new \Exception(sprintf('Unsupported mode "%s"', $mode)); } return $this; }
php
public function flip(&$image, $mode){ if ($mode === 'h') { $image->getCore()->flopImage(); } else if ($mode === 'v') { $image->getCore()->flipImage(); } else { throw new \Exception(sprintf('Unsupported mode "%s"', $mode)); } return $this; }
[ "public", "function", "flip", "(", "&", "$", "image", ",", "$", "mode", ")", "{", "if", "(", "$", "mode", "===", "'h'", ")", "{", "$", "image", "->", "getCore", "(", ")", "->", "flopImage", "(", ")", ";", "}", "else", "if", "(", "$", "mode", ...
Flip or mirrors the image. @param Image $image @param string $mode The type of flip: 'h' for horizontal flip or 'v' for vertical. @return Editor @throws \Exception
[ "Flip", "or", "mirrors", "the", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L317-L326
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.isAvailable
public function isAvailable() { // First, test Imagick's extension and classes. if (false === extension_loaded('imagick') || false === class_exists('Imagick') || false === class_exists('ImagickDraw') || false === class_exists('ImagickPixel') || false =...
php
public function isAvailable() { // First, test Imagick's extension and classes. if (false === extension_loaded('imagick') || false === class_exists('Imagick') || false === class_exists('ImagickDraw') || false === class_exists('ImagickPixel') || false =...
[ "public", "function", "isAvailable", "(", ")", "{", "// First, test Imagick's extension and classes.", "if", "(", "false", "===", "extension_loaded", "(", "'imagick'", ")", "||", "false", "===", "class_exists", "(", "'Imagick'", ")", "||", "false", "===", "class_exi...
Checks if the editor is available on the current PHP install. @return bool True if available false if not.
[ "Checks", "if", "the", "editor", "is", "available", "on", "the", "current", "PHP", "install", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L346-L359
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.opacity
public function opacity(&$image, $opacity) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } // Bounds checks $opacity = ($opacity > 1) ? 1 : $opacity; $opacity = ($opacity < 0) ? 0 : $opacity; $image->getCore()->setImageOpaci...
php
public function opacity(&$image, $opacity) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } // Bounds checks $opacity = ($opacity > 1) ? 1 : $opacity; $opacity = ($opacity < 0) ? 0 : $opacity; $image->getCore()->setImageOpaci...
[ "public", "function", "opacity", "(", "&", "$", "image", ",", "$", "opacity", ")", "{", "if", "(", "$", "image", "->", "isAnimated", "(", ")", ")", "{", "// Ignore animated GIF for now", "return", "$", "this", ";", "}", "// Bounds checks", "$", "opacity", ...
Sets the image to the specified opacity level where 1.0 is fully opaque and 0.0 is fully transparent. @param Image $image @param float $opacity @return self @throws \Exception
[ "Sets", "the", "image", "to", "the", "specified", "opacity", "level", "where", "1", ".", "0", "is", "fully", "opaque", "and", "0", ".", "0", "is", "fully", "transparent", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L370-L384
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.resize
public function resize(&$image, $newWidth, $newHeight, $mode = 'fit') { /* * Resize formula: * ratio = w / h * h = w / ratio * w = h * ratio */ switch ($mode) { case 'exact': $this->resizeExact($image, $newWidth, $newHeight); ...
php
public function resize(&$image, $newWidth, $newHeight, $mode = 'fit') { /* * Resize formula: * ratio = w / h * h = w / ratio * w = h * ratio */ switch ($mode) { case 'exact': $this->resizeExact($image, $newWidth, $newHeight); ...
[ "public", "function", "resize", "(", "&", "$", "image", ",", "$", "newWidth", ",", "$", "newHeight", ",", "$", "mode", "=", "'fit'", ")", "{", "/*\n * Resize formula:\n * ratio = w / h\n * h = w / ratio\n * w = h * ratio\n */", "switc...
Wrapper function for the resizeXXX family of functions. Resize image given width, height and mode. @param Image $image @param int $newWidth Width in pixels. @param int $newHeight Height in pixels. @param string $mode Resize mode. Possible values: "exact", "exactHeight", "exactWidth", "fill", "fit". @return Editor @th...
[ "Wrapper", "function", "for", "the", "resizeXXX", "family", "of", "functions", ".", "Resize", "image", "given", "width", "height", "and", "mode", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L410-L439
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.resizeExact
public function resizeExact(&$image, $newWidth, $newHeight) { $this->_resize($image, $newWidth, $newHeight); return $this; }
php
public function resizeExact(&$image, $newWidth, $newHeight) { $this->_resize($image, $newWidth, $newHeight); return $this; }
[ "public", "function", "resizeExact", "(", "&", "$", "image", ",", "$", "newWidth", ",", "$", "newHeight", ")", "{", "$", "this", "->", "_resize", "(", "$", "image", ",", "$", "newWidth", ",", "$", "newHeight", ")", ";", "return", "$", "this", ";", ...
Resize image to exact dimensions ignoring aspect ratio. Useful if you want to force exact width and height. @param Image $image @param int $newWidth Width in pixels. @param int $newHeight Height in pixels. @return self
[ "Resize", "image", "to", "exact", "dimensions", "ignoring", "aspect", "ratio", ".", "Useful", "if", "you", "want", "to", "force", "exact", "width", "and", "height", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L450-L456
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.resizeExactHeight
public function resizeExactHeight(&$image, $newHeight) { $width = $image->getWidth(); $height = $image->getHeight(); $ratio = $width / $height; $resizeHeight = $newHeight; $resizeWidth = $newHeight * $ratio; $this->_resize($image, $resizeWidth, $resizeHeight); ...
php
public function resizeExactHeight(&$image, $newHeight) { $width = $image->getWidth(); $height = $image->getHeight(); $ratio = $width / $height; $resizeHeight = $newHeight; $resizeWidth = $newHeight * $ratio; $this->_resize($image, $resizeWidth, $resizeHeight); ...
[ "public", "function", "resizeExactHeight", "(", "&", "$", "image", ",", "$", "newHeight", ")", "{", "$", "width", "=", "$", "image", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "image", "->", "getHeight", "(", ")", ";", "$", "ratio", ...
Resize image to exact height. Width is auto calculated. Useful for creating row of images with the same height. @param Image $image @param int $newHeight Height in pixels. @return self
[ "Resize", "image", "to", "exact", "height", ".", "Width", "is", "auto", "calculated", ".", "Useful", "for", "creating", "row", "of", "images", "with", "the", "same", "height", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L466-L479
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.resizeExactWidth
public function resizeExactWidth(&$image, $newWidth) { $width = $image->getWidth(); $height = $image->getHeight(); $ratio = $width / $height; $resizeWidth = $newWidth; $resizeHeight = round($newWidth / $ratio); $this->_resize($image, $resizeWidth, $resizeHeight)...
php
public function resizeExactWidth(&$image, $newWidth) { $width = $image->getWidth(); $height = $image->getHeight(); $ratio = $width / $height; $resizeWidth = $newWidth; $resizeHeight = round($newWidth / $ratio); $this->_resize($image, $resizeWidth, $resizeHeight)...
[ "public", "function", "resizeExactWidth", "(", "&", "$", "image", ",", "$", "newWidth", ")", "{", "$", "width", "=", "$", "image", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "image", "->", "getHeight", "(", ")", ";", "$", "ratio", "=...
Resize image to exact width. Height is auto calculated. Useful for creating column of images with the same width. @param Image $image @param int $newWidth Width in pixels. @return self
[ "Resize", "image", "to", "exact", "width", ".", "Height", "is", "auto", "calculated", ".", "Useful", "for", "creating", "column", "of", "images", "with", "the", "same", "width", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L489-L502
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.resizeFill
public function resizeFill(&$image, $newWidth, $newHeight) { $width = $image->getWidth(); $height = $image->getHeight(); $ratio = $width / $height; // Base optimum size on new width $optimumWidth = $newWidth; $optimumHeight = round($newWidth / $ratio); if...
php
public function resizeFill(&$image, $newWidth, $newHeight) { $width = $image->getWidth(); $height = $image->getHeight(); $ratio = $width / $height; // Base optimum size on new width $optimumWidth = $newWidth; $optimumHeight = round($newWidth / $ratio); if...
[ "public", "function", "resizeFill", "(", "&", "$", "image", ",", "$", "newWidth", ",", "$", "newHeight", ")", "{", "$", "width", "=", "$", "image", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "image", "->", "getHeight", "(", ")", ";",...
Resize image to fill all the space in the given dimension. Excess parts are cropped. @param Image $image @param int $newWidth Width in pixels. @param int $newHeight Height in pixels. @return self
[ "Resize", "image", "to", "fill", "all", "the", "space", "in", "the", "given", "dimension", ".", "Excess", "parts", "are", "cropped", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L513-L533
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.resizeFit
public function resizeFit(&$image, $newWidth, $newHeight) { $width = $image->getWidth(); $height = $image->getHeight(); $ratio = $width / $height; // Try basing it on width first $resizeWidth = $newWidth; $resizeHeight = round($newWidth / $ratio); if (($...
php
public function resizeFit(&$image, $newWidth, $newHeight) { $width = $image->getWidth(); $height = $image->getHeight(); $ratio = $width / $height; // Try basing it on width first $resizeWidth = $newWidth; $resizeHeight = round($newWidth / $ratio); if (($...
[ "public", "function", "resizeFit", "(", "&", "$", "image", ",", "$", "newWidth", ",", "$", "newHeight", ")", "{", "$", "width", "=", "$", "image", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "image", "->", "getHeight", "(", ")", ";", ...
Resize image to fit inside the given dimension. No part of the image is lost. @param Image $image @param int $newWidth Width in pixels. @param int $newHeight Height in pixels. @return self
[ "Resize", "image", "to", "fit", "inside", "the", "given", "dimension", ".", "No", "part", "of", "the", "image", "is", "lost", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L544-L564
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.rotate
public function rotate(&$image, $angle, $color = null) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $color = ($color !== null) ? $color : new Color('#000000'); list($r, $g, $b, $alpha) = $color->getRgba(); $image->getCore()->rota...
php
public function rotate(&$image, $angle, $color = null) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $color = ($color !== null) ? $color : new Color('#000000'); list($r, $g, $b, $alpha) = $color->getRgba(); $image->getCore()->rota...
[ "public", "function", "rotate", "(", "&", "$", "image", ",", "$", "angle", ",", "$", "color", "=", "null", ")", "{", "if", "(", "$", "image", "->", "isAnimated", "(", ")", ")", "{", "// Ignore animated GIF for now", "return", "$", "this", ";", "}", "...
Rotate an image counter-clockwise. @param Image $image @param int $angle The angle in degrees. @param Color|null $color The Color object containing the background color. @return EditorInterface An instance of image editor.
[ "Rotate", "an", "image", "counter", "-", "clockwise", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L575-L588
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.save
public function save( $image, $file, $type = null, $quality = null, $interlace = false, $permission = 0755) { if (null === $type) { $type = $this->_getImageTypeFromFileName($file); // Null given, guess type from file extension if (ImageType::UNKNOWN === $type) { $ty...
php
public function save( $image, $file, $type = null, $quality = null, $interlace = false, $permission = 0755) { if (null === $type) { $type = $this->_getImageTypeFromFileName($file); // Null given, guess type from file extension if (ImageType::UNKNOWN === $type) { $ty...
[ "public", "function", "save", "(", "$", "image", ",", "$", "file", ",", "$", "type", "=", "null", ",", "$", "quality", "=", "null", ",", "$", "interlace", "=", "false", ",", "$", "permission", "=", "0755", ")", "{", "if", "(", "null", "===", "$",...
Save the image to an image format. @param Image $image @param string $file File path where to save the image. @param null|string $type Type of image. Can be null, "GIF", "PNG", or "JPEG". @param null|string $quality Quality of image. Applies to JPEG only. Accepts number 0 - 100 where 0 is lowest and 100 is the highest...
[ "Save", "the", "image", "to", "an", "image", "format", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L603-L648
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor.text
public function text(&$image, $text, $size = 12, $x = 0, $y = 0, $color = null, $font = '', $angle = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $y += $size; $color = ($color !== null) ? $color : new Color('#000000'); $font ...
php
public function text(&$image, $text, $size = 12, $x = 0, $y = 0, $color = null, $font = '', $angle = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $y += $size; $color = ($color !== null) ? $color : new Color('#000000'); $font ...
[ "public", "function", "text", "(", "&", "$", "image", ",", "$", "text", ",", "$", "size", "=", "12", ",", "$", "x", "=", "0", ",", "$", "y", "=", "0", ",", "$", "color", "=", "null", ",", "$", "font", "=", "''", ",", "$", "angle", "=", "0...
Write text to image. @param Image $image @param string $text The text to be written. @param int $size The font size. Defaults to 12. @param int $x The distance from the left edge of the image to the left of the text. Defaults to 0. @param int $y The distance from the top edge of the image to the top of the text. Defau...
[ "Write", "text", "to", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L665-L697
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor._entropy
private function _entropy($hist){ $entropy = 0; $hist_size = array_sum($hist['r']) + array_sum($hist['g']) + array_sum($hist['b']); foreach($hist['r'] as $p){ $p = $p / $hist_size; $entropy += $p * log($p, 2); } foreach($hist['g'] as $p){ $p = ...
php
private function _entropy($hist){ $entropy = 0; $hist_size = array_sum($hist['r']) + array_sum($hist['g']) + array_sum($hist['b']); foreach($hist['r'] as $p){ $p = $p / $hist_size; $entropy += $p * log($p, 2); } foreach($hist['g'] as $p){ $p = ...
[ "private", "function", "_entropy", "(", "$", "hist", ")", "{", "$", "entropy", "=", "0", ";", "$", "hist_size", "=", "array_sum", "(", "$", "hist", "[", "'r'", "]", ")", "+", "array_sum", "(", "$", "hist", "[", "'g'", "]", ")", "+", "array_sum", ...
Calculate entropy based on histogram. @param array $hist Histogram returned by Image->histogram @return float|int
[ "Calculate", "entropy", "based", "on", "histogram", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L706-L722
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor._smartCrop
private function _smartCrop($oldImage, $cropW, $cropH){ $image = clone $oldImage; $this->resizeFit($image, 30, 30); $origW = $oldImage->getWidth(); $origH = $oldImage->getHeight(); $resizeW = $image->getWidth(); $resizeH = $image->getHeight(); $smallCropW = rou...
php
private function _smartCrop($oldImage, $cropW, $cropH){ $image = clone $oldImage; $this->resizeFit($image, 30, 30); $origW = $oldImage->getWidth(); $origH = $oldImage->getHeight(); $resizeW = $image->getWidth(); $resizeH = $image->getHeight(); $smallCropW = rou...
[ "private", "function", "_smartCrop", "(", "$", "oldImage", ",", "$", "cropW", ",", "$", "cropH", ")", "{", "$", "image", "=", "clone", "$", "oldImage", ";", "$", "this", "->", "resizeFit", "(", "$", "image", ",", "30", ",", "30", ")", ";", "$", "...
Crop based on entropy. @param Image $oldImage @param $cropW @param $cropH @return array
[ "Crop", "based", "on", "entropy", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L733-L768
kosinix/grafika
src/Grafika/Imagick/Editor.php
Editor._resize
private function _resize(&$image, $newWidth, $newHeight) { if ('GIF' == $image->getType()) { // Animated image. Eg. GIF $imagick = $image->getCore()->coalesceImages(); foreach ($imagick as $frame) { $frame->resizeImage($newWidth, $newHeight, \Imagick::FILTER_BOX, 1...
php
private function _resize(&$image, $newWidth, $newHeight) { if ('GIF' == $image->getType()) { // Animated image. Eg. GIF $imagick = $image->getCore()->coalesceImages(); foreach ($imagick as $frame) { $frame->resizeImage($newWidth, $newHeight, \Imagick::FILTER_BOX, 1...
[ "private", "function", "_resize", "(", "&", "$", "image", ",", "$", "newWidth", ",", "$", "newHeight", ")", "{", "if", "(", "'GIF'", "==", "$", "image", "->", "getType", "(", ")", ")", "{", "// Animated image. Eg. GIF", "$", "imagick", "=", "$", "image...
Resize helper function. @param Image $image @param int $newWidth @param int $newHeight @return self @throws \Exception
[ "Resize", "helper", "function", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Editor.php#L780-L803
kosinix/grafika
src/Grafika/Gd/Filter/Blur.php
Blur.apply
public function apply($image) { for ($i=0; $i < $this->amount; $i++) { imagefilter($image->getCore(), IMG_FILTER_GAUSSIAN_BLUR); } return $image; }
php
public function apply($image) { for ($i=0; $i < $this->amount; $i++) { imagefilter($image->getCore(), IMG_FILTER_GAUSSIAN_BLUR); } return $image; }
[ "public", "function", "apply", "(", "$", "image", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "amount", ";", "$", "i", "++", ")", "{", "imagefilter", "(", "$", "image", "->", "getCore", "(", ")", ",", "IMG...
@param Image $image @return Image
[ "@param", "Image", "$image" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Filter/Blur.php#L33-L39
kosinix/grafika
src/Grafika/Imagick/Image.php
Image.createFromFile
public static function createFromFile( $imageFile ){ $imageFile = realpath( $imageFile ); if ( ! file_exists( $imageFile ) ) { throw new \Exception( sprintf('Could not open image file "%s"', $imageFile) ); } $imagick = new \Imagick( realpath($imageFile) ); $animated...
php
public static function createFromFile( $imageFile ){ $imageFile = realpath( $imageFile ); if ( ! file_exists( $imageFile ) ) { throw new \Exception( sprintf('Could not open image file "%s"', $imageFile) ); } $imagick = new \Imagick( realpath($imageFile) ); $animated...
[ "public", "static", "function", "createFromFile", "(", "$", "imageFile", ")", "{", "$", "imageFile", "=", "realpath", "(", "$", "imageFile", ")", ";", "if", "(", "!", "file_exists", "(", "$", "imageFile", ")", ")", "{", "throw", "new", "\\", "Exception",...
@param $imageFile @return Image @throws \Exception
[ "@param", "$imageFile" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Image.php#L88-L109
kosinix/grafika
src/Grafika/Imagick/Image.php
Image.createFromCore
public static function createFromCore( $imagick ) { return new self( $imagick, '', $imagick->getImageWidth(), $imagick->getImageHeight(), $imagick->getImageFormat() ); }
php
public static function createFromCore( $imagick ) { return new self( $imagick, '', $imagick->getImageWidth(), $imagick->getImageHeight(), $imagick->getImageFormat() ); }
[ "public", "static", "function", "createFromCore", "(", "$", "imagick", ")", "{", "return", "new", "self", "(", "$", "imagick", ",", "''", ",", "$", "imagick", "->", "getImageWidth", "(", ")", ",", "$", "imagick", "->", "getImageHeight", "(", ")", ",", ...
Create an Image from an instance of Imagick. @param \Imagick $imagick Instance of Imagick. @return Image
[ "Create", "an", "Image", "from", "an", "instance", "of", "Imagick", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Image.php#L118-L120
kosinix/grafika
src/Grafika/Imagick/Image.php
Image.createBlank
public static function createBlank($width = 1, $height = 1){ $imagick = new \Imagick(); $imagick->newImage($width, $height, new \ImagickPixel('black')); $imagick->setImageFormat('png'); // Default to PNG. return new self( $imagick, '', $imagick->getImageWidth(), $imagick->getImageHeight...
php
public static function createBlank($width = 1, $height = 1){ $imagick = new \Imagick(); $imagick->newImage($width, $height, new \ImagickPixel('black')); $imagick->setImageFormat('png'); // Default to PNG. return new self( $imagick, '', $imagick->getImageWidth(), $imagick->getImageHeight...
[ "public", "static", "function", "createBlank", "(", "$", "width", "=", "1", ",", "$", "height", "=", "1", ")", "{", "$", "imagick", "=", "new", "\\", "Imagick", "(", ")", ";", "$", "imagick", "->", "newImage", "(", "$", "width", ",", "$", "height",...
Create a blank image. @param int $width Width in pixels. @param int $height Height in pixels. @return self
[ "Create", "a", "blank", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Image.php#L130-L137
kosinix/grafika
src/Grafika/Imagick/Image.php
Image.histogram
public function histogram($slice = null) { if(null === $slice){ $sliceX = 0; $sliceY = 0; $sliceW = $this->getWidth(); $sliceH = $this->getHeight(); } else { $sliceX = $slice[0][0]; $sliceY = $slice[0][1]; $sliceW =...
php
public function histogram($slice = null) { if(null === $slice){ $sliceX = 0; $sliceY = 0; $sliceW = $this->getWidth(); $sliceH = $this->getHeight(); } else { $sliceX = $slice[0][0]; $sliceY = $slice[0][1]; $sliceW =...
[ "public", "function", "histogram", "(", "$", "slice", "=", "null", ")", "{", "if", "(", "null", "===", "$", "slice", ")", "{", "$", "sliceX", "=", "0", ";", "$", "sliceY", "=", "0", ";", "$", "sliceW", "=", "$", "this", "->", "getWidth", "(", "...
Get histogram from an entire image or its sub-region. @param array|null $slice Array of slice information. array( array( 0,0), array(100,50)) means x,y is 0,0 and width,height is 100,50 @return array Returns array containing RGBA bins array('r'=>array(), 'g'=>array(), 'b'=>array(), 'a'=>array())
[ "Get", "histogram", "from", "an", "entire", "image", "or", "its", "sub", "-", "region", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Image.php#L191-L258
kosinix/grafika
src/Grafika/Grafika.php
Grafika.detectAvailableEditor
public static function detectAvailableEditor($editorList = null) { if(null === $editorList){ $editorList = self::$editorList; } /* Get first supported editor instance. Order of editorList matter. */ foreach ($editorList as $editorName) { if ('Imagick' === $e...
php
public static function detectAvailableEditor($editorList = null) { if(null === $editorList){ $editorList = self::$editorList; } /* Get first supported editor instance. Order of editorList matter. */ foreach ($editorList as $editorName) { if ('Imagick' === $e...
[ "public", "static", "function", "detectAvailableEditor", "(", "$", "editorList", "=", "null", ")", "{", "if", "(", "null", "===", "$", "editorList", ")", "{", "$", "editorList", "=", "self", "::", "$", "editorList", ";", "}", "/* Get first supported editor ins...
Detects and return the name of the first supported editor which can either be "Imagick" or "Gd". @param array $editorList Array of editor list names. Use this to change the order of evaluation for editors for this function call only. Default order of evaluation is Imagick then GD. @return string Name of available edi...
[ "Detects", "and", "return", "the", "name", "of", "the", "first", "supported", "editor", "which", "can", "either", "be", "Imagick", "or", "Gd", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Grafika.php#L95-L116
kosinix/grafika
src/Grafika/Grafika.php
Grafika.createImage
public static function createImage($imageFile) { $editorName = self::detectAvailableEditor(); if ('Imagick' === $editorName) { return ImagickImage::createFromFile($imageFile); } else { return GdImage::createFromFile($imageFile); } }
php
public static function createImage($imageFile) { $editorName = self::detectAvailableEditor(); if ('Imagick' === $editorName) { return ImagickImage::createFromFile($imageFile); } else { return GdImage::createFromFile($imageFile); } }
[ "public", "static", "function", "createImage", "(", "$", "imageFile", ")", "{", "$", "editorName", "=", "self", "::", "detectAvailableEditor", "(", ")", ";", "if", "(", "'Imagick'", "===", "$", "editorName", ")", "{", "return", "ImagickImage", "::", "createF...
Create an image. @param string $imageFile Path to image file. @return ImageInterface @throws \Exception
[ "Create", "an", "image", ".", "@param", "string", "$imageFile", "Path", "to", "image", "file", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Grafika.php#L143-L151
kosinix/grafika
src/Grafika/Grafika.php
Grafika.createBlankImage
public static function createBlankImage($width = 1, $height = 1) { $editorName = self::detectAvailableEditor(); if ('Imagick' === $editorName) { return ImagickImage::createBlank($width, $height); } else { return GdImage::createBlank($width, $height); } }
php
public static function createBlankImage($width = 1, $height = 1) { $editorName = self::detectAvailableEditor(); if ('Imagick' === $editorName) { return ImagickImage::createBlank($width, $height); } else { return GdImage::createBlank($width, $height); } }
[ "public", "static", "function", "createBlankImage", "(", "$", "width", "=", "1", ",", "$", "height", "=", "1", ")", "{", "$", "editorName", "=", "self", "::", "detectAvailableEditor", "(", ")", ";", "if", "(", "'Imagick'", "===", "$", "editorName", ")", ...
Create a blank image. @param int $width Width of image in pixels. @param int $height Height of image in pixels. @return ImageInterface @throws \Exception
[ "Create", "a", "blank", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Grafika.php#L163-L171
kosinix/grafika
src/Grafika/Grafika.php
Grafika.createFilter
public static function createFilter($filterName) { $editorName = self::detectAvailableEditor(); $p = func_get_args(); if ('Imagick' === $editorName) { switch ($filterName){ case 'Blur': return new ImagickBlur( (array_key...
php
public static function createFilter($filterName) { $editorName = self::detectAvailableEditor(); $p = func_get_args(); if ('Imagick' === $editorName) { switch ($filterName){ case 'Blur': return new ImagickBlur( (array_key...
[ "public", "static", "function", "createFilter", "(", "$", "filterName", ")", "{", "$", "editorName", "=", "self", "::", "detectAvailableEditor", "(", ")", ";", "$", "p", "=", "func_get_args", "(", ")", ";", "if", "(", "'Imagick'", "===", "$", "editorName",...
Create a filter. Detects available editor to use. @param string $filterName The name of the filter. @return FilterInterface @throws \Exception
[ "Create", "a", "filter", ".", "Detects", "available", "editor", "to", "use", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Grafika.php#L182-L271
kosinix/grafika
src/Grafika/Grafika.php
Grafika.createDrawingObject
public static function createDrawingObject($drawingObjectName) { $editorName = self::detectAvailableEditor(); $p = func_get_args(); if ('Imagick' === $editorName) { switch ($drawingObjectName){ case 'CubicBezier': return new ImagickCubicBezier(...
php
public static function createDrawingObject($drawingObjectName) { $editorName = self::detectAvailableEditor(); $p = func_get_args(); if ('Imagick' === $editorName) { switch ($drawingObjectName){ case 'CubicBezier': return new ImagickCubicBezier(...
[ "public", "static", "function", "createDrawingObject", "(", "$", "drawingObjectName", ")", "{", "$", "editorName", "=", "self", "::", "detectAvailableEditor", "(", ")", ";", "$", "p", "=", "func_get_args", "(", ")", ";", "if", "(", "'Imagick'", "===", "$", ...
Draws an object. Detects available editor to use. @param string $drawingObjectName The name of the DrawingObject. @return DrawingObjectInterface @throws \Exception We use array_key_exist() instead of isset() to be able to detect a parameter with a NULL value.
[ "Draws", "an", "object", ".", "Detects", "available", "editor", "to", "use", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Grafika.php#L283-L391
kosinix/grafika
src/Grafika/Imagick/Filter/Colorize.php
Colorize.apply
public function apply( $image ) { // normalize colorize levels $red = $this->normalizeLevel($this->red); $green = $this->normalizeLevel($this->green); $blue = $this->normalizeLevel($this->blue); $qrange = $image->getCore()->getQuantumRange(); $image->getCore()->levelIma...
php
public function apply( $image ) { // normalize colorize levels $red = $this->normalizeLevel($this->red); $green = $this->normalizeLevel($this->green); $blue = $this->normalizeLevel($this->blue); $qrange = $image->getCore()->getQuantumRange(); $image->getCore()->levelIma...
[ "public", "function", "apply", "(", "$", "image", ")", "{", "// normalize colorize levels", "$", "red", "=", "$", "this", "->", "normalizeLevel", "(", "$", "this", "->", "red", ")", ";", "$", "green", "=", "$", "this", "->", "normalizeLevel", "(", "$", ...
@param Image $image @return Image
[ "@param", "Image", "$image" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Filter/Colorize.php#L44-L57
kosinix/grafika
src/Grafika/Gd/Image.php
Image.blob
public function blob( $type = 'PNG' ) { $type = strtoupper($type); if ( ImageType::GIF == $type ) { imagegif( $this->gd ); } else if ( ImageType::JPEG == $type ) { imagejpeg( $this->gd ); } else if ( ImageType::PNG == $type ) { imagepng( $this->g...
php
public function blob( $type = 'PNG' ) { $type = strtoupper($type); if ( ImageType::GIF == $type ) { imagegif( $this->gd ); } else if ( ImageType::JPEG == $type ) { imagejpeg( $this->gd ); } else if ( ImageType::PNG == $type ) { imagepng( $this->g...
[ "public", "function", "blob", "(", "$", "type", "=", "'PNG'", ")", "{", "$", "type", "=", "strtoupper", "(", "$", "type", ")", ";", "if", "(", "ImageType", "::", "GIF", "==", "$", "type", ")", "{", "imagegif", "(", "$", "this", "->", "gd", ")", ...
Output a binary raw dump of an image in a specified format. @param string|ImageType $type Image format of the dump. @throws \Exception When unsupported type.
[ "Output", "a", "binary", "raw", "dump", "of", "an", "image", "in", "a", "specified", "format", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Image.php#L90-L112
kosinix/grafika
src/Grafika/Gd/Image.php
Image.createFromFile
public static function createFromFile( $imageFile ) { if ( ! file_exists( $imageFile ) ) { throw new \Exception( sprintf( 'Could not open "%s". File does not exist.', $imageFile ) ); } $type = self::_guessType( $imageFile ); if ( ImageType::GIF == $type ) { retu...
php
public static function createFromFile( $imageFile ) { if ( ! file_exists( $imageFile ) ) { throw new \Exception( sprintf( 'Could not open "%s". File does not exist.', $imageFile ) ); } $type = self::_guessType( $imageFile ); if ( ImageType::GIF == $type ) { retu...
[ "public", "static", "function", "createFromFile", "(", "$", "imageFile", ")", "{", "if", "(", "!", "file_exists", "(", "$", "imageFile", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Could not open \"%s\". File does not exist.'", ",", ...
Create Image from image file. @param string $imageFile Path to image. @return Image @throws \Exception
[ "Create", "Image", "from", "image", "file", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Image.php#L122-L147
kosinix/grafika
src/Grafika/Gd/Image.php
Image.createFromCore
public static function createFromCore( $gd ) { return new self( $gd, '', imagesx( $gd ), imagesy( $gd ), ImageType::UNKNOWN ); }
php
public static function createFromCore( $gd ) { return new self( $gd, '', imagesx( $gd ), imagesy( $gd ), ImageType::UNKNOWN ); }
[ "public", "static", "function", "createFromCore", "(", "$", "gd", ")", "{", "return", "new", "self", "(", "$", "gd", ",", "''", ",", "imagesx", "(", "$", "gd", ")", ",", "imagesy", "(", "$", "gd", ")", ",", "ImageType", "::", "UNKNOWN", ")", ";", ...
Create an Image from a GD resource. The file type defaults to unknown. @param resource $gd GD resource. @return Image
[ "Create", "an", "Image", "from", "a", "GD", "resource", ".", "The", "file", "type", "defaults", "to", "unknown", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Image.php#L156-L158
kosinix/grafika
src/Grafika/Gd/Image.php
Image.createBlank
public static function createBlank($width = 1, $height = 1){ return new self(imagecreatetruecolor($width, $height), '', $width, $height, ImageType::UNKNOWN); }
php
public static function createBlank($width = 1, $height = 1){ return new self(imagecreatetruecolor($width, $height), '', $width, $height, ImageType::UNKNOWN); }
[ "public", "static", "function", "createBlank", "(", "$", "width", "=", "1", ",", "$", "height", "=", "1", ")", "{", "return", "new", "self", "(", "imagecreatetruecolor", "(", "$", "width", ",", "$", "height", ")", ",", "''", ",", "$", "width", ",", ...
Create a blank image. @param int $width Width in pixels. @param int $height Height in pixels. @return Image
[ "Create", "a", "blank", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Image.php#L168-L172
kosinix/grafika
src/Grafika/Gd/Image.php
Image.fullAlphaMode
public function fullAlphaMode( $flag ){ if( true === $flag ){ $this->alphaBlendingMode( false ); // Must be false for full alpha mode to work } imagesavealpha( $this->gd, $flag ); return $this; }
php
public function fullAlphaMode( $flag ){ if( true === $flag ){ $this->alphaBlendingMode( false ); // Must be false for full alpha mode to work } imagesavealpha( $this->gd, $flag ); return $this; }
[ "public", "function", "fullAlphaMode", "(", "$", "flag", ")", "{", "if", "(", "true", "===", "$", "flag", ")", "{", "$", "this", "->", "alphaBlendingMode", "(", "false", ")", ";", "// Must be false for full alpha mode to work", "}", "imagesavealpha", "(", "$",...
Enable/Disable transparency @param bool $flag True to enable alpha mode. @return self
[ "Enable", "/", "Disable", "transparency" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Image.php#L192-L199
kosinix/grafika
src/Grafika/Gd/Image.php
Image.histogram
public function histogram($slice = null) { $gd = $this->getCore(); if(null === $slice){ $sliceX = 0; $sliceY = 0; $sliceW = $this->getWidth(); $sliceH = $this->getHeight(); } else { $sliceX = $slice[0][0]; $sliceY = $sl...
php
public function histogram($slice = null) { $gd = $this->getCore(); if(null === $slice){ $sliceX = 0; $sliceY = 0; $sliceW = $this->getWidth(); $sliceH = $this->getHeight(); } else { $sliceX = $slice[0][0]; $sliceY = $sl...
[ "public", "function", "histogram", "(", "$", "slice", "=", "null", ")", "{", "$", "gd", "=", "$", "this", "->", "getCore", "(", ")", ";", "if", "(", "null", "===", "$", "slice", ")", "{", "$", "sliceX", "=", "0", ";", "$", "sliceY", "=", "0", ...
Get histogram from an entire image or its sub-region. @param array|null $slice Array of slice information. array( array( 0,0), array(100,50)) means x,y is 0,0 and width,height is 100,50 @return array Returns array containing RGBA bins array('r'=>array(), 'g'=>array(), 'b'=>array(), 'a'=>array())
[ "Get", "histogram", "from", "an", "entire", "image", "or", "its", "sub", "-", "region", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Image.php#L271-L330
kosinix/grafika
src/Grafika/Gd/Image.php
Image._createGif
private static function _createGif( $imageFile ){ $gift = new GifHelper(); $bytes = $gift->open($imageFile); $animated = $gift->isAnimated($bytes); $blocks = ''; if($animated){ $blocks = $gift->decode($bytes); } $gd = @imagecreatefromgif( $imageFile );...
php
private static function _createGif( $imageFile ){ $gift = new GifHelper(); $bytes = $gift->open($imageFile); $animated = $gift->isAnimated($bytes); $blocks = ''; if($animated){ $blocks = $gift->decode($bytes); } $gd = @imagecreatefromgif( $imageFile );...
[ "private", "static", "function", "_createGif", "(", "$", "imageFile", ")", "{", "$", "gift", "=", "new", "GifHelper", "(", ")", ";", "$", "bytes", "=", "$", "gift", "->", "open", "(", "$", "imageFile", ")", ";", "$", "animated", "=", "$", "gift", "...
Load a GIF image. @param string $imageFile @return Image @throws \Exception
[ "Load", "a", "GIF", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Image.php#L340-L363
kosinix/grafika
src/Grafika/Gd/Image.php
Image._createJpeg
private static function _createJpeg( $imageFile ){ $gd = @imagecreatefromjpeg( $imageFile ); if(!$gd){ throw new \Exception( sprintf('Could not open "%s". Not a valid %s file.', $imageFile, ImageType::JPEG ) ); } return new self( $gd, $imageFile, imagesx( $gd ), imagesy( $g...
php
private static function _createJpeg( $imageFile ){ $gd = @imagecreatefromjpeg( $imageFile ); if(!$gd){ throw new \Exception( sprintf('Could not open "%s". Not a valid %s file.', $imageFile, ImageType::JPEG ) ); } return new self( $gd, $imageFile, imagesx( $gd ), imagesy( $g...
[ "private", "static", "function", "_createJpeg", "(", "$", "imageFile", ")", "{", "$", "gd", "=", "@", "imagecreatefromjpeg", "(", "$", "imageFile", ")", ";", "if", "(", "!", "$", "gd", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", ...
Load a JPEG image. @param string $imageFile File path to image. @return Image @throws \Exception
[ "Load", "a", "JPEG", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Image.php#L373-L381
kosinix/grafika
src/Grafika/Gd/Image.php
Image._createPng
private static function _createPng( $imageFile ){ $gd = @imagecreatefrompng( $imageFile ); if(!$gd){ throw new \Exception( sprintf('Could not open "%s". Not a valid %s file.', $imageFile, ImageType::PNG) ); } $image = new self( $gd, $imageFile, imagesx( $gd ), imagesy( $gd ...
php
private static function _createPng( $imageFile ){ $gd = @imagecreatefrompng( $imageFile ); if(!$gd){ throw new \Exception( sprintf('Could not open "%s". Not a valid %s file.', $imageFile, ImageType::PNG) ); } $image = new self( $gd, $imageFile, imagesx( $gd ), imagesy( $gd ...
[ "private", "static", "function", "_createPng", "(", "$", "imageFile", ")", "{", "$", "gd", "=", "@", "imagecreatefrompng", "(", "$", "imageFile", ")", ";", "if", "(", "!", "$", "gd", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "...
Load a PNG image. @param string $imageFile File path to image. @return Image @throws \Exception
[ "Load", "a", "PNG", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Image.php#L391-L401
kosinix/grafika
src/Grafika/Gd/Image.php
Image._createWbmp
private static function _createWbmp( $imageFile ){ $gd = @imagecreatefromwbmp( $imageFile ); if(!$gd){ throw new \Exception( sprintf('Could not open "%s". Not a valid %s file.', $imageFile, ImageType::WBMP) ); } return new self( $gd, $imageFile, imagesx( $gd ), imagesy( $gd...
php
private static function _createWbmp( $imageFile ){ $gd = @imagecreatefromwbmp( $imageFile ); if(!$gd){ throw new \Exception( sprintf('Could not open "%s". Not a valid %s file.', $imageFile, ImageType::WBMP) ); } return new self( $gd, $imageFile, imagesx( $gd ), imagesy( $gd...
[ "private", "static", "function", "_createWbmp", "(", "$", "imageFile", ")", "{", "$", "gd", "=", "@", "imagecreatefromwbmp", "(", "$", "imageFile", ")", ";", "if", "(", "!", "$", "gd", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", ...
Load a WBMP image. @param string $imageFile @return Image @throws \Exception
[ "Load", "a", "WBMP", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Image.php#L411-L419
kosinix/grafika
src/Grafika/Gd/Image.php
Image._guessType
private static function _guessType( $imageFile ){ // Values from http://php.net/manual/en/image.constants.php starting with IMAGETYPE_GIF. // 0 - unknown, // 1 - GIF, // 2 - JPEG, // 3 - PNG // 15 - WBMP list($width, $height, $type) = getimagesize( $imageFile ); ...
php
private static function _guessType( $imageFile ){ // Values from http://php.net/manual/en/image.constants.php starting with IMAGETYPE_GIF. // 0 - unknown, // 1 - GIF, // 2 - JPEG, // 3 - PNG // 15 - WBMP list($width, $height, $type) = getimagesize( $imageFile ); ...
[ "private", "static", "function", "_guessType", "(", "$", "imageFile", ")", "{", "// Values from http://php.net/manual/en/image.constants.php starting with IMAGETYPE_GIF.", "// 0 - unknown,", "// 1 - GIF,", "// 2 - JPEG,", "// 3 - PNG", "// 15 - WBMP", "list", "(", "$", "width", ...
@param $imageFile @return string
[ "@param", "$imageFile" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Image.php#L426-L456
kosinix/grafika
src/Grafika/Imagick/DrawingObject/Line.php
Line.draw
public function draw($image) { $strokeColor = new \ImagickPixel($this->getColor()->getHexString()); $draw = new \ImagickDraw(); $draw->setStrokeColor($strokeColor); $draw->setStrokeWidth($this->thickness); list($x1, $y1) = $this->point1; list($x2, $y2) = $this->p...
php
public function draw($image) { $strokeColor = new \ImagickPixel($this->getColor()->getHexString()); $draw = new \ImagickDraw(); $draw->setStrokeColor($strokeColor); $draw->setStrokeWidth($this->thickness); list($x1, $y1) = $this->point1; list($x2, $y2) = $this->p...
[ "public", "function", "draw", "(", "$", "image", ")", "{", "$", "strokeColor", "=", "new", "\\", "ImagickPixel", "(", "$", "this", "->", "getColor", "(", ")", "->", "getHexString", "(", ")", ")", ";", "$", "draw", "=", "new", "\\", "ImagickDraw", "("...
@param Image $image @return Image
[ "@param", "Image", "$image" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/DrawingObject/Line.php#L20-L38
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor.blend
public function blend(&$image1, $image2, $type='normal', $opacity = 1.0, $position = 'top-left', $offsetX = 0, $offsetY = 0 ){ // Turn into position object $position = new Position($position, $offsetX, $offsetY); // Position is for $image2. $image1 is canvas. list($offsetX, $offsetY) =...
php
public function blend(&$image1, $image2, $type='normal', $opacity = 1.0, $position = 'top-left', $offsetX = 0, $offsetY = 0 ){ // Turn into position object $position = new Position($position, $offsetX, $offsetY); // Position is for $image2. $image1 is canvas. list($offsetX, $offsetY) =...
[ "public", "function", "blend", "(", "&", "$", "image1", ",", "$", "image2", ",", "$", "type", "=", "'normal'", ",", "$", "opacity", "=", "1.0", ",", "$", "position", "=", "'top-left'", ",", "$", "offsetX", "=", "0", ",", "$", "offsetY", "=", "0", ...
Blend two images together with the first image as the base and the second image on top. Supports several blend modes. @param Image $image1 The base image. @param Image $image2 The image placed on top of the base image. @param string $type The blend mode. Can be: normal, multiply, overlay or screen. @param float $opaci...
[ "Blend", "two", "images", "together", "with", "the", "first", "image", "as", "the", "base", "and", "the", "second", "image", "on", "top", ".", "Supports", "several", "blend", "modes", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L57-L141
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor.crop
public function crop( &$image, $cropWidth, $cropHeight, $position = 'center', $offsetX = 0, $offsetY = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } if ( 'smart' === $position ) { // Smart crop list( $x, $y ) = $this->_smartCrop( $i...
php
public function crop( &$image, $cropWidth, $cropHeight, $position = 'center', $offsetX = 0, $offsetY = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } if ( 'smart' === $position ) { // Smart crop list( $x, $y ) = $this->_smartCrop( $i...
[ "public", "function", "crop", "(", "&", "$", "image", ",", "$", "cropWidth", ",", "$", "cropHeight", ",", "$", "position", "=", "'center'", ",", "$", "offsetX", "=", "0", ",", "$", "offsetY", "=", "0", ")", "{", "if", "(", "$", "image", "->", "is...
Crop the image to the given dimension and position. @param Image $image @param int $cropWidth Crop width in pixels. @param int $cropHeight Crop Height in pixels. @param string $position The crop position. Possible values top-left, top-center, top-right, center-left, center, center-right, bottom-left, bottom-center, bo...
[ "Crop", "the", "image", "to", "the", "given", "dimension", "and", "position", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L195-L243
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor.equal
public function equal($image1, $image2) { if (is_string($image1)) { // If string passed, turn it into a Image object $image1 = Image::createFromFile($image1); $this->flatten( $image1 ); } if (is_string($image2)) { // If string passed, turn it into a Image object ...
php
public function equal($image1, $image2) { if (is_string($image1)) { // If string passed, turn it into a Image object $image1 = Image::createFromFile($image1); $this->flatten( $image1 ); } if (is_string($image2)) { // If string passed, turn it into a Image object ...
[ "public", "function", "equal", "(", "$", "image1", ",", "$", "image2", ")", "{", "if", "(", "is_string", "(", "$", "image1", ")", ")", "{", "// If string passed, turn it into a Image object", "$", "image1", "=", "Image", "::", "createFromFile", "(", "$", "im...
Compare if two images are equal. It will compare if the two images are of the same width and height. If the dimensions differ, it will return false. If the dimensions are equal, it will loop through each pixels. If one of the pixel don't match, it will return false. The pixels are compared using their RGB (Red, Green, ...
[ "Compare", "if", "two", "images", "are", "equal", ".", "It", "will", "compare", "if", "the", "two", "images", "are", "of", "the", "same", "width", "and", "height", ".", "If", "the", "dimensions", "differ", "it", "will", "return", "false", ".", "If", "t...
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L274-L323
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor.fill
public function fill( &$image, $color, $x = 0, $y = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } list($r, $g, $b, $alpha) = $color->getRgba(); $colorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, $this->...
php
public function fill( &$image, $color, $x = 0, $y = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } list($r, $g, $b, $alpha) = $color->getRgba(); $colorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, $this->...
[ "public", "function", "fill", "(", "&", "$", "image", ",", "$", "color", ",", "$", "x", "=", "0", ",", "$", "y", "=", "0", ")", "{", "if", "(", "$", "image", "->", "isAnimated", "(", ")", ")", "{", "// Ignore animated GIF for now", "return", "$", ...
Fill entire image with color. @param Image $image @param Color $color Color object @param int $x X-coordinate of start point @param int $y Y-coordinate of start point @return Editor
[ "Fill", "entire", "image", "with", "color", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L335-L349
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor.flatten
public function flatten(&$image){ if($image->isAnimated()) { $old = $image->getCore(); $gift = new GifHelper(); $hex = $gift->encode($image->getBlocks()); $gd = imagecreatefromstring(pack('H*', $hex)); // Recreate resource from blocks imagedestroy...
php
public function flatten(&$image){ if($image->isAnimated()) { $old = $image->getCore(); $gift = new GifHelper(); $hex = $gift->encode($image->getBlocks()); $gd = imagecreatefromstring(pack('H*', $hex)); // Recreate resource from blocks imagedestroy...
[ "public", "function", "flatten", "(", "&", "$", "image", ")", "{", "if", "(", "$", "image", "->", "isAnimated", "(", ")", ")", "{", "$", "old", "=", "$", "image", "->", "getCore", "(", ")", ";", "$", "gift", "=", "new", "GifHelper", "(", ")", "...
Flatten if animated GIF. Do nothing otherwise. @param Image $image @return Editor
[ "Flatten", "if", "animated", "GIF", ".", "Do", "nothing", "otherwise", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L358-L378
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor.opacity
public function opacity( &$image, $opacity ) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } // Bounds checks $opacity = ($opacity > 1) ? 1 : $opacity; $opacity = ($opacity < 0) ? 0 : $opacity; for ($y = 0; $y < $image->getH...
php
public function opacity( &$image, $opacity ) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } // Bounds checks $opacity = ($opacity > 1) ? 1 : $opacity; $opacity = ($opacity < 0) ? 0 : $opacity; for ($y = 0; $y < $image->getH...
[ "public", "function", "opacity", "(", "&", "$", "image", ",", "$", "opacity", ")", "{", "if", "(", "$", "image", "->", "isAnimated", "(", ")", ")", "{", "// Ignore animated GIF for now", "return", "$", "this", ";", "}", "// Bounds checks", "$", "opacity", ...
Sets the image to the specified opacity level where 1.0 is fully opaque and 0.0 is fully transparent. Warning: This function loops thru each pixel manually which can be slow. Use sparingly. @param Image $image @param float $opacity @return Editor @throws \Exception
[ "Sets", "the", "image", "to", "the", "specified", "opacity", "level", "where", "1", ".", "0", "is", "fully", "opaque", "and", "0", ".", "0", "is", "fully", "transparent", ".", "Warning", ":", "This", "function", "loops", "thru", "each", "pixel", "manuall...
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L453-L486
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor.rotate
public function rotate(&$image, $angle, $color = null) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $color = ($color !== null) ? $color : new Color('#000000'); list($r, $g, $b, $alpha) = $color->getRgba(); $old = $image->getCore(...
php
public function rotate(&$image, $angle, $color = null) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $color = ($color !== null) ? $color : new Color('#000000'); list($r, $g, $b, $alpha) = $color->getRgba(); $old = $image->getCore(...
[ "public", "function", "rotate", "(", "&", "$", "image", ",", "$", "angle", ",", "$", "color", "=", "null", ")", "{", "if", "(", "$", "image", "->", "isAnimated", "(", ")", ")", "{", "// Ignore animated GIF for now", "return", "$", "this", ";", "}", "...
Rotate an image counter-clockwise. @param Image $image @param int $angle The angle in degrees. @param Color|null $color The Color object containing the background color. @return EditorInterface An instance of image editor. @throws \Exception
[ "Rotate", "an", "image", "counter", "-", "clockwise", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L678-L699
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor.save
public function save($image, $file, $type = null, $quality = null, $interlace = false, $permission = 0755) { if (null === $type) { $type = $this->_getImageTypeFromFileName($file); // Null given, guess type from file extension if (ImageType::UNKNOWN === $type) { $typ...
php
public function save($image, $file, $type = null, $quality = null, $interlace = false, $permission = 0755) { if (null === $type) { $type = $this->_getImageTypeFromFileName($file); // Null given, guess type from file extension if (ImageType::UNKNOWN === $type) { $typ...
[ "public", "function", "save", "(", "$", "image", ",", "$", "file", ",", "$", "type", "=", "null", ",", "$", "quality", "=", "null", ",", "$", "interlace", "=", "false", ",", "$", "permission", "=", "0755", ")", "{", "if", "(", "null", "===", "$",...
Save the image to an image format. @param Image $image @param string $file File path where to save the image. @param null|string $type Type of image. Can be null, "GIF", "PNG", or "JPEG". @param null|string $quality Quality of image. Applies to JPEG only. Accepts number 0 - 100 where 0 is lowest and 100 is the highest...
[ "Save", "the", "image", "to", "an", "image", "format", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L714-L760
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor.text
public function text(&$image, $text, $size = 12, $x = 0, $y = 0, $color = null, $font = '', $angle = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $y += $size; $color = ($color !== null) ? $color : new Color('#000000'); $font ...
php
public function text(&$image, $text, $size = 12, $x = 0, $y = 0, $color = null, $font = '', $angle = 0) { if ($image->isAnimated()) { // Ignore animated GIF for now return $this; } $y += $size; $color = ($color !== null) ? $color : new Color('#000000'); $font ...
[ "public", "function", "text", "(", "&", "$", "image", ",", "$", "text", ",", "$", "size", "=", "12", ",", "$", "x", "=", "0", ",", "$", "y", "=", "0", ",", "$", "color", "=", "null", ",", "$", "font", "=", "''", ",", "$", "angle", "=", "0...
Write text to image. @param Image $image @param string $text The text to be written. @param int $size The font size. Defaults to 12. @param int $x The distance from the left edge of the image to the left of the text. Defaults to 0. @param int $y The distance from the top edge of the image to the top of the text. Defau...
[ "Write", "text", "to", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L777-L809
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor._blendMultiply
private function _blendMultiply($canvas, $gd1, $gd2, $loopStartY, $loopEndY, $loopStartX, $loopEndX, $offsetX, $offsetY, $opacity){ for ( $y = $loopStartY; $y < $loopEndY; $y++ ) { for ( $x = $loopStartX; $x < $loopEndX; $x++ ) { $canvasX = $x + $offsetX; $canvasY...
php
private function _blendMultiply($canvas, $gd1, $gd2, $loopStartY, $loopEndY, $loopStartX, $loopEndX, $offsetX, $offsetY, $opacity){ for ( $y = $loopStartY; $y < $loopEndY; $y++ ) { for ( $x = $loopStartX; $x < $loopEndX; $x++ ) { $canvasX = $x + $offsetX; $canvasY...
[ "private", "function", "_blendMultiply", "(", "$", "canvas", ",", "$", "gd1", ",", "$", "gd2", ",", "$", "loopStartY", ",", "$", "loopEndY", ",", "$", "loopStartX", ",", "$", "loopEndX", ",", "$", "offsetX", ",", "$", "offsetY", ",", "$", "opacity", ...
@param $canvas @param $gd1 @param $gd2 @param $loopStartY @param $loopEndY @param $loopStartX @param $loopEndX @param $offsetX @param $offsetY @param $opacity @return $this
[ "@param", "$canvas", "@param", "$gd1", "@param", "$gd2", "@param", "$loopStartY", "@param", "$loopEndY", "@param", "$loopStartX", "@param", "$loopEndX", "@param", "$offsetX", "@param", "$offsetY" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L826-L855
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor._flip
private function _flip($image, $mode) { $old = $image->getCore(); $w = $image->getWidth(); $h = $image->getHeight(); if ($mode === 'h') { $new = imagecreatetruecolor($w, $h); for ($x = 0; $x < $w; $x++) { imagecopy($new, $old, $w - $x - 1, ...
php
private function _flip($image, $mode) { $old = $image->getCore(); $w = $image->getWidth(); $h = $image->getHeight(); if ($mode === 'h') { $new = imagecreatetruecolor($w, $h); for ($x = 0; $x < $w; $x++) { imagecopy($new, $old, $w - $x - 1, ...
[ "private", "function", "_flip", "(", "$", "image", ",", "$", "mode", ")", "{", "$", "old", "=", "$", "image", "->", "getCore", "(", ")", ";", "$", "w", "=", "$", "image", "->", "getWidth", "(", ")", ";", "$", "h", "=", "$", "image", "->", "ge...
Flips image. @param Image $image @param $mode @return Image @throws \Exception
[ "Flips", "image", ".", "@param", "Image", "$image", "@param", "$mode" ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L1002-L1040
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor._getImageTypeFromFileName
private function _getImageTypeFromFileName($imageFile) { $ext = strtolower((string)pathinfo($imageFile, PATHINFO_EXTENSION)); if ('jpg' === $ext or 'jpeg' === $ext) { return ImageType::JPEG; } else if ('gif' === $ext) { return ImageType::GIF; } else if ('png'...
php
private function _getImageTypeFromFileName($imageFile) { $ext = strtolower((string)pathinfo($imageFile, PATHINFO_EXTENSION)); if ('jpg' === $ext or 'jpeg' === $ext) { return ImageType::JPEG; } else if ('gif' === $ext) { return ImageType::GIF; } else if ('png'...
[ "private", "function", "_getImageTypeFromFileName", "(", "$", "imageFile", ")", "{", "$", "ext", "=", "strtolower", "(", "(", "string", ")", "pathinfo", "(", "$", "imageFile", ",", "PATHINFO_EXTENSION", ")", ")", ";", "if", "(", "'jpg'", "===", "$", "ext",...
Get image type base on file extension. @param int $imageFile File path to image. @return ImageType string Type of image.
[ "Get", "image", "type", "base", "on", "file", "extension", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L1049-L1064
kosinix/grafika
src/Grafika/Gd/Editor.php
Editor._resize
private function _resize(&$image, $newWidth, $newHeight, $targetX = 0, $targetY = 0, $srcX = 0, $srcY = 0) { // $this->_imageCheck(); if ($image->isAnimated()) { // Animated GIF $gift = new GifHelper(); $blocks = $gift->resize($image->getBlocks(), $newWidth, $newHeight); ...
php
private function _resize(&$image, $newWidth, $newHeight, $targetX = 0, $targetY = 0, $srcX = 0, $srcY = 0) { // $this->_imageCheck(); if ($image->isAnimated()) { // Animated GIF $gift = new GifHelper(); $blocks = $gift->resize($image->getBlocks(), $newWidth, $newHeight); ...
[ "private", "function", "_resize", "(", "&", "$", "image", ",", "$", "newWidth", ",", "$", "newHeight", ",", "$", "targetX", "=", "0", ",", "$", "targetY", "=", "0", ",", "$", "srcX", "=", "0", ",", "$", "srcY", "=", "0", ")", "{", "// $thi...
Resize helper function. @param Image $image @param int $newWidth @param int $newHeight @param int $targetX @param int $targetY @param int $srcX @param int $srcY
[ "Resize", "helper", "function", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/Editor.php#L1078-L1132
kosinix/grafika
src/Grafika/Imagick/ImageHash/DifferenceHash.php
DifferenceHash.hash
public function hash($image, $editor) { $width = 9; $height = 8; $image = clone $image; // Make sure we are working on the clone if Image is passed $editor->resizeExact($image, $width, $height); // Resize to exactly 9x8 $imagick = $image->getCore(); // Build hash ...
php
public function hash($image, $editor) { $width = 9; $height = 8; $image = clone $image; // Make sure we are working on the clone if Image is passed $editor->resizeExact($image, $width, $height); // Resize to exactly 9x8 $imagick = $image->getCore(); // Build hash ...
[ "public", "function", "hash", "(", "$", "image", ",", "$", "editor", ")", "{", "$", "width", "=", "9", ";", "$", "height", "=", "8", ";", "$", "image", "=", "clone", "$", "image", ";", "// Make sure we are working on the clone if Image is passed", "$", "ed...
Generate and get the difference hash of image. @param Image $image @param Editor $editor @return string
[ "Generate", "and", "get", "the", "difference", "hash", "of", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/ImageHash/DifferenceHash.php#L34-L66
kosinix/grafika
src/Grafika/Imagick/Filter/Dither.php
Dither.apply
public function apply( $image ) { if ( $this->type === 'ordered' ) { return $this->ordered( $image ); } else if ( $this->type === 'diffusion' ) { return $this->diffusion( $image ); } throw new \Exception( sprintf( 'Invalid dither type "%s".', $this->type ) ); ...
php
public function apply( $image ) { if ( $this->type === 'ordered' ) { return $this->ordered( $image ); } else if ( $this->type === 'diffusion' ) { return $this->diffusion( $image ); } throw new \Exception( sprintf( 'Invalid dither type "%s".', $this->type ) ); ...
[ "public", "function", "apply", "(", "$", "image", ")", "{", "if", "(", "$", "this", "->", "type", "===", "'ordered'", ")", "{", "return", "$", "this", "->", "ordered", "(", "$", "image", ")", ";", "}", "else", "if", "(", "$", "this", "->", "type"...
Apply filter. @param Image $image @return Image @throws \Exception
[ "Apply", "filter", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Filter/Dither.php#L36-L43
kosinix/grafika
src/Grafika/Imagick/Filter/Dither.php
Dither.diffusion
private function diffusion( $image ){ $pixels = array(); // Localize vars $width = $image->getWidth(); $height = $image->getHeight(); // Loop using image1 $pixelIterator = $image->getCore()->getPixelIterator(); foreach ($pixelIterator as $y => $rows) { /* Loop t...
php
private function diffusion( $image ){ $pixels = array(); // Localize vars $width = $image->getWidth(); $height = $image->getHeight(); // Loop using image1 $pixelIterator = $image->getCore()->getPixelIterator(); foreach ($pixelIterator as $y => $rows) { /* Loop t...
[ "private", "function", "diffusion", "(", "$", "image", ")", "{", "$", "pixels", "=", "array", "(", ")", ";", "// Localize vars", "$", "width", "=", "$", "image", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "image", "->", "getHeight", "(...
Dither using error diffusion. @param Image $image @return Image
[ "Dither", "using", "error", "diffusion", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Filter/Dither.php#L52-L114
kosinix/grafika
src/Grafika/Imagick/Filter/Dither.php
Dither.ordered
private function ordered( $image ) { // Localize vars $width = $image->getWidth(); $height = $image->getHeight(); $thresholdMap = array( array( 15, 135, 45, 165 ), array( 195, 75, 225, 105 ), array( 60, 180, 30, 150 ), array( 240, 120, 21...
php
private function ordered( $image ) { // Localize vars $width = $image->getWidth(); $height = $image->getHeight(); $thresholdMap = array( array( 15, 135, 45, 165 ), array( 195, 75, 225, 105 ), array( 60, 180, 30, 150 ), array( 240, 120, 21...
[ "private", "function", "ordered", "(", "$", "image", ")", "{", "// Localize vars", "$", "width", "=", "$", "image", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "image", "->", "getHeight", "(", ")", ";", "$", "thresholdMap", "=", "array", ...
Dither by applying a threshold map. @param Image $image @return Image
[ "Dither", "by", "applying", "a", "threshold", "map", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Imagick/Filter/Dither.php#L123-L167
kosinix/grafika
src/Grafika/Gd/ImageHash/AverageHash.php
AverageHash.hash
public function hash($image, $editor) { // Resize the image. $width = 8; $height = 8; $image = clone $image; // Make sure we are working on the clone if Image is passed $editor->resizeExact($image, $width, $height); // Resize to exactly 8x8 $gd = $image->getCore(); ...
php
public function hash($image, $editor) { // Resize the image. $width = 8; $height = 8; $image = clone $image; // Make sure we are working on the clone if Image is passed $editor->resizeExact($image, $width, $height); // Resize to exactly 8x8 $gd = $image->getCore(); ...
[ "public", "function", "hash", "(", "$", "image", ",", "$", "editor", ")", "{", "// Resize the image.", "$", "width", "=", "8", ";", "$", "height", "=", "8", ";", "$", "image", "=", "clone", "$", "image", ";", "// Make sure we are working on the clone if Imag...
Generate and get the average hash of the image. @param Image $image @param Editor $editor @return string
[ "Generate", "and", "get", "the", "average", "hash", "of", "the", "image", "." ]
train
https://github.com/kosinix/grafika/blob/211f61fc334b8b36616b23e8af7c5727971d96ee/src/Grafika/Gd/ImageHash/AverageHash.php#L35-L70