Configure the new TinyMCE to have almost the same buttons as the old one.
Configure the new TinyMCE to have almost the same buttons as the old one.

File last commit:

c3da001f5ff1
3cf3f8fd35f8
Show More
images.php
57 lines | 1.2 KiB | text/x-php | PhpLexer
<?php
function getimagefromfile($filename)
{
$img_data = getimagesize($filename);
$ext = image_type_to_extension($img_data[2]);
switch($ext)
{
case '.gif':
return imagecreatefromgif($filename);
break;
case '.jpg':
case '.jpeg':
return imagecreatefromjpeg($filename);
break;
case '.png':
return imagecreatefrompng($filename);
break;
default:
return false;
}
}
function crop_resize($filename, $dest_file)
{
#REQUIRES: image be at least 300x245
$source = getimagefromfile($filename);
if(!$source)
{
return false;
}
$dest = imagecreatetruecolor(300, 245);
#attempt to determine scaling factor
$data = getimagesize($filename);
#300x245 reduces to 60x49
$factor = min(floor($data[0]/60), floor($data[1]/49));
#well, that should give us a good scaling factor
#now we have to determine what point to start from
$src_x = floor(($data[0]/2) - ($factor*30));
$src_y = floor(($data[1]/2) - ($factor*24.5));
#make sure we don't fuck things up
if($src_x < 0) $src_x=0;
if($src_y < 0) $src_y=0;
#now resample
imagecopyresampled($dest, $source, 0, 0, $src_x, $src_y, 300, 245, $factor*60, $factor*49);
#and output
imagepng($dest, $dest_file);
return true;
}
?>