Re: Image Rotation Script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




There are tons of (free) jquery gadgets that do image rotation. All you'd need to do is push the list out to the jquery script.

Cheers,
Curtis

On 10/15/2011 10:50 AM, dev@xxxxxxxx wrote:
We have a simple script which rotates and image to a random value, saves
it to a cache directory and displays it. For some reason when I move the
script from a Debian box over to the production CentOS machine, it no
longer caches any of the images. the rest works, but not the cache. If you
could look at it and see if anything jumps out at you, please let me know.

install the code below to the directory /angles


.htaccess:
RewriteEngine on
RewriteRule ^rotate_(\d+)(?:_(?:\d+))?.png$ rotate.php?im=$1

rotate.php:
<?php
// Setup
if(isset($_GET['im'])&&  file_exists($_GET['im'].'.png')) {
header('Content-type: image/png');
$im = $_GET['im'].'.png';
$degrees = rand(0, 360);
$save = 'cache/'.$_GET['im'].'_'.$degrees.'.png';
if(!file_exists($save)) {
// Rotate via "command line" and cache it
exec('convert '.$im.' -filter \'Lanczos\' -resize \'150x150\' -rotate
'.$degrees.' -black-threshold 40% '.$save, $out);
}
// Output out (newly?) cached file
echo file_get_contents($save);
} else {
die("Image not found");
}
?>

Use it by url:
http://www.servername.com/angles/rotate_019.png
Each time you reload page the angle should rotate to a new position.




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux