Created
March 5, 2013 20:57
-
-
Save designedbyscience/5094209 to your computer and use it in GitHub Desktop.
Using ImagicMagick with Wordpress (Specifically doing a color image overlay)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function make_blue_image($data){ | |
if(!empty($data)) { | |
$upload_dir = wp_upload_dir(); | |
if(!empty($data['sizes']) && array_key_exists('blue', $data['sizes'])) { | |
$filepath = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . dirname($data['file']) . DIRECTORY_SEPARATOR . $data['sizes']['blue']['file']; | |
} | |
//Image to lay on top | |
$bluepath = TEMPLATEPATH . "/blue.png"; | |
//Path to ImagicMagick could be different (this is homebrew) | |
$command = "/usr/local/bin/composite " . $bluepath ." ". $filepath ." -compose Multiply -gravity center " . $filepath . " 2>&1"; | |
} | |
// pass forward attachment metadata | |
return $data; | |
} | |
add_filter('wp_generate_attachment_metadata', 'make_blue_image'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment