Here’s how to draw an arc using PHP Imagick
newImage(200, 200,new ImagickPixel("white"),'png'); $arc = new ImagickDraw(); $arc->setFillColor('red'); $arc->setStrokeColor('black'); $arc->setStrokeWidth(2); // x1,x2,y1,y2, start angle, end angle $arc->arc(30, 30, 160, 160, -70, 70); $canvas->drawImage($arc); $canvas->borderImage('black', 1, 1); header('content-type: image/png'); echo $canvas->getImage(); exit();
Produces:
Save as PDF
Here’s how to cache an object using Zend_Cache:
<?php $cache_frontend_options = array( 'lifetime' => 3600, // cache lifetime of 1 hour 'automatic_serialization' => false ); $cache_backend_options = array( 'servers' => array( array('host' => 'localhost', 'port' => 11211, 'persistent' => true) ), 'compression' => false ); $cache = Zend_Cache::factory('Core', 'Memcached', $cache_frontend_options, $cache_backend_options); $key = 'myUniqueId-123'; $cache_object = $cache->load($key); if ($cache_object === false) { // not in cache $object = new myObject(); $cache->save(serialize($object), $key); } else { // in cache $object = unserialize($cache_object); }
Note: The reason that "automatic_serialization" is set to false and then I manually serialize and unserialize is that "automatic_serialization" didn’t work.
On an Ubuntu System:
sudo apt-get install imagemagick libmagick9-dev php5-imagick php5-dev wget http://pecl.php.net/get/imagick-3.0.0b1.tgz tar xvfz imagick-3.0.0b1.tgz cd imagick-3.0.0b1 phpize && ./configure sudo make sudo make install sudo apache2ctl graceful
<?php //Create two Imagick objects $first = new Imagick('tshirt.png'); $second = new Imagick('photo.jpg'); $first->compositeImage($second, Imagick::COMPOSITE_MULTIPLY, 220, 141); //new image is saved as final.jpg $first->setImageFormat('jpg'); header('content-type: image/jpeg'); echo $first->getImage(); ?>
I’ve never liked using Rhythmbox (Gnome’s default music player) as I found previous versions to be slow, buggy and crashed a lot. I’m trying to keep my system as close as possible to the default install so I’ve given Rythmbox one more change to impress.
I found the MTP plugin (in preferences > plugins) and enabled it, connected my Creative Zen 4GB and am happy to say it showed up and works.
Goodbye Gnomad2!
UPDATE 05/01/2010
I found rhythmbox to be far too unstable and tried Banshee (http://banshee-project.org/). The Creative Zen works fantastically with the Banshee MTP plugin on Ubuntu 9.10 and Banshee 1.6 Beta 2 (1.5.1).