Skip to content

Instantly share code, notes, and snippets.

@designedbyscience
Created March 5, 2013 20:57
Show Gist options
  • Save designedbyscience/5094209 to your computer and use it in GitHub Desktop.
Save designedbyscience/5094209 to your computer and use it in GitHub Desktop.
Using ImagicMagick with Wordpress (Specifically doing a color image overlay)
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