Skip to content

Instantly share code, notes, and snippets.

@fecori
Created October 16, 2019 22:06
Show Gist options
  • Select an option

  • Save fecori/6dd71d773a4b1e619ce469d5d8d7e194 to your computer and use it in GitHub Desktop.

Select an option

Save fecori/6dd71d773a4b1e619ce469d5d8d7e194 to your computer and use it in GitHub Desktop.
Generar imagenes thumbor con php
<?php
$imgTest = 'https://arc-anglerfish-arc2-prod-gruporepublica.s3.amazonaws.com/public/GDAJPDXRN5EJHNC22N6FTPAWEA.png';
function generarImagen($imgUrl, $witdh = 0, $height = 0)
{
if (!empty($imgUrl) && strpos($imgUrl, 'https') !== false) {
$thumbor_server = "SERVER";
$thumbor_key = "APIKEY";
$parametros = array(
$witdh . "x" . $height,
"top",
"smart",
);
$parametros[] = str_replace("https://", "", $imgUrl);
$thumbor_url_params = implode('/', $parametros);
$thumbor_hmac = base64_encode(hash_hmac('sha1', $thumbor_url_params, $thumbor_key, true));
$thumbor_hmac = str_replace(array('+', '/'), array('-', '_'), $thumbor_hmac);
return $thumbor_server . '/' . $thumbor_hmac . '/' . $thumbor_url_params;
}
return "no existe url";
}
echo generarImagen($imgTest, 100, 130);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment