Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env php
- <?php
- $content = file_get_contents($argv[1]);
- function invert_color($matches) {
- $r = 255 - intval(substr($matches[1], 0, 2), 16);
- $g = 255 - intval(substr($matches[1], 2, 2), 16);
- $b = 255 - intval(substr($matches[1], 4, 2), 16);
- $a = isset($matches[2]) ? $matches[2] : '';
- return sprintf("#%02x%02x%02x%s", $r, $g, $b, $a);
- }
- $inverted = preg_replace_callback('@\#([a-f0-9]{6})([a-f0-9]{2})?@i', 'invert_color', $content);
- file_put_contents($argv[1] . '.inv', $inverted);
Add Comment
Please, Sign In to add comment