Skip to content

Instantly share code, notes, and snippets.

@rsky
Last active June 6, 2016 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsky/422f3e687d47588fb63a01418adf1674 to your computer and use it in GitHub Desktop.
Save rsky/422f3e687d47588fb63a01418adf1674 to your computer and use it in GitHub Desktop.
透明チャンネルをそのままに塗り潰し色を変える
<?php
// usage: php change_fill_color.php '#cafe00' < in.png > out.png
$color = $_SERVER['argv'][1];
$in = new Imagick();
$in->readImageFile(STDIN);
$size = $in->getImageGeometry();
$out = new Imagick();
$out->newImage($size['width'], $size['height'], $color);
$out->setImageFormat('png');
$out->compositeImage($in, Imagick::COMPOSITE_COPYOPACITY, 0, 0);
$out->writeImageFile(STDOUT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment