Skip to content
Snippets Groups Projects
Commit 68375754 authored by Pavel Vitis's avatar Pavel Vitis
Browse files

support for ImageMagicks convert in fetch.php

This patch allows one to set $conf['im_convert'] to use ImageMagick
instead of PHPs libGD to resize images. convert is more powerful
than libGD - it can resize animated gifs for example.

darcs-hash:20050911140225-c484b-10fbb66d003c839debc98edf814e261bddea3aa6.gz
parent 42208b03
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,7 @@ $conf['locktime'] = 15*60; //maximum age for lockfiles (defaults t
$conf['notify'] = ''; //send change info to this email (leave blank for nobody)
$conf['mailfrom'] = ''; //use this email when sending mails
$conf['gdlib'] = 2; //the GDlib version (0, 1 or 2) 2 tries to autodetect
$conf['im_convert'] = ''; //path to ImageMagicks convert (will be used instead of GD)
$conf['spellchecker']= 0; //enable Spellchecker (needs PHP >= 4.3.0 and aspell installed)
$conf['subscribers'] = 0; //enable change notice subscription support
$conf['pluginmanager'] = 0; //enable automated plugin management (requires plugin)
......
......@@ -114,7 +114,9 @@ function get_resized($file, $ext, $w, $h=0){
$local = getCacheName($file,'.media.'.$w.'x'.$h.'.'.$ext);
$mtime = @filemtime($local); // 0 if not exists
if( $mtime > filemtime($file) || resize_image($ext,$file,$info[0],$info[1],$local,$w,$h) ){
if( $mtime > filemtime($file) ||
resize_imageIM($ext,$file,$info[0],$info[1],$local,$w,$h) ||
resize_imageGD($ext,$file,$info[0],$info[1],$local,$w,$h) ){
return $local;
}
//still here? resizing failed
......@@ -143,23 +145,25 @@ function calc_cache($cache){
* wanted
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Pavel Vitis <Pavel.Vitis@seznam.cz>
*/
function get_from_URL($url,$ext,$cache){
global $conf;
$url = strtolower($url);
$local = getCacheName($url,".media.$ext");
$local = getCacheName(strtolower($url),".media.$ext");
$mtime = @filemtime($local); // 0 if not exists
//decide if download needed:
// never cache exists but no endless cache not exists or expired
if( $cache == 0 || ($mtime != 0 && $cache != -1) || $mtime < time()-$cache ){
if(io_download($url,$local)){
return $local;
}else{
return false;
}
if( $cache == 0 || // never cache
($mtime != 0 && $cache != -1) || // exists but no endless cache
($mtime == 0) || // not exists
($cache != -1 && $mtime < time()-$cache) // expired
){
if(io_download($url,$local)){
return $local;
}else{
return false;
}
}
//if cache exists use it else
......@@ -170,11 +174,34 @@ function get_from_URL($url,$ext,$cache){
}
/**
* resize images
* resize images using external ImageMagick convert program
*
* @author Pavel Vitis <Pavel.Vitis@seznam.cz>
* @author Andreas Gohr <andi@splitbrain.org>
*/
function resize_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){
global $conf;
// check if convert is configured and available
if(!@is_executable($conf['im_convert'])) return false;
// prepare command
$cmd = $conf['im_convert'];
$cmd .= ' -resize '.$to_w.'x'.$to_h.'!';
$cmd .= " $from $to";
@exec($cmd,$out,$retval);
if ($retval == 0) return true;
return false;
}
/**
* resize images using PHP's libGD support
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function resize_image($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){
function resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){
global $conf;
if($conf['gdlib'] < 1) return false; //no GDlib available or wanted
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment