Guest User

Untitled

a guest
Apr 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #!/usr/bin/env php
  2. <?php
  3. $content = file_get_contents($argv[1]);
  4.  
  5. function invert_color($matches) {
  6. $r = 255 - intval(substr($matches[1], 0, 2), 16);
  7. $g = 255 - intval(substr($matches[1], 2, 2), 16);
  8. $b = 255 - intval(substr($matches[1], 4, 2), 16);
  9. $a = isset($matches[2]) ? $matches[2] : '';
  10.  
  11. return sprintf("#%02x%02x%02x%s", $r, $g, $b, $a);
  12. }
  13.  
  14. $inverted = preg_replace_callback('@\#([a-f0-9]{6})([a-f0-9]{2})?@i', 'invert_color', $content);
  15. file_put_contents($argv[1] . '.inv', $inverted);
Add Comment
Please, Sign In to add comment