Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • K konnect-bundle
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Delivery
  • Public
  • Open source
  • konnect-bundle
  • Issues
  • #25
Closed
Open
Created Dec 06, 2019 by hlarget@d3cima👹Owner

Create route for image resizing

This route should receive an url in get parameter (check for base64), with size parameters and send it to the image resizer and return it as a binary response image.

<?php

$resize = 'fit';
$width = 300;
$height = 300;
$gravity = 'no';
$enlarge = 1;
$extension = 'png';
$url = 'https://aboutgoods-test.ams3.digitaloceanspaces.com/aboutg-6-a184-4098-9b37-af45c3266d96/3129dd23-9f4e-4bf0-a771-9d829f94955d';
$encodedUrl = rtrim(strtr(base64_encode($url), '+/', '-_'), '=');

$key = '41626F7574676F6F6473';
$salt = '436F6D70616E79';
$keyBin = pack("H*" , $key);
if(empty($keyBin)) {
	die('Key expected to be hex-encoded string');
}
$saltBin = pack("H*" , $salt);
if(empty($saltBin)) {
	die('Salt expected to be hex-encoded string');
}

$path = "/{$resize}/{$width}/{$height}/{$gravity}/{$enlarge}/{$encodedUrl}.{$extension}";
$signature = rtrim(strtr(base64_encode(hash_hmac('sha256', $saltBin.$path, $keyBin, true)), '+/', '-_'), '=');
print(sprintf("/%s%s", $signature, $path));
Edited Dec 06, 2019 by hlarget
Assignee
Assign to
Time tracking