Skip to content

Instantly share code, notes, and snippets.

@serefyarar
Last active January 4, 2016 03:09
Show Gist options
  • Save serefyarar/8559903 to your computer and use it in GitHub Desktop.
Save serefyarar/8559903 to your computer and use it in GitHub Desktop.
Transparent text with imagemagick
<?php
$position = 'waist';
$size = 'normal';
$letters = 'SRT';
$color = "000000";
$font = 'arial';
$positions = array(
'waist'=>array(358,440,-6)
);
$sizes = array(
'normal'=>array(415,503),
'zoom'=>array(415,503),
);
$image = new Imagick();
$draw = new ImagickDraw();
$pixel = new ImagickPixel("rgba(255,255,255,0)");
$image->newImage($sizes[$size][0], $sizes[$size][1], $pixel);
$draw->setFillColor($color);
$draw->setFont($font.'.ttf');
$draw->setFontSize(8);
$image->annotateImage($draw, $positions[$position][0], $positions[$position][1], $positions[$position][2], $letters);
$image->setImageFormat('png');
header('Content-type: image/png');
echo $image;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment