added: a new winix function: imgcrop

for cropping images (and thumbnails)
       www.domain.com/dir/file.jpg/imgcrop  -- crop an image
       www.domain.com/dir/file.jpg/imgcrop/thumb  -- crop an image's thumbnail
       www.domain.com/dir/file.jpg/imgcrop/newthumb  -- crop and create a new thumbnail (from an original image)
       www.domain.com/dir/imgcrop -- show images' list with above options
added: to Image class: some methods for cropping




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@919 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2013-03-29 22:03:28 +00:00
parent 8d9a021eab
commit 495499d12f
27 changed files with 1374 additions and 793 deletions

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2012, Tomasz Sowa
* Copyright (c) 2008-2013, Tomasz Sowa
* All rights reserved.
*
*/
@@ -89,68 +89,16 @@ bool Upload::UploadSaveStaticFile(const Item & item, const std::wstring & tmp_fi
void Upload::ResizeImage(Item & item)
{
::Mount * m = system->mounts.CalcMount(item.parent_id);
size_t cx = config->image_cx;
size_t cy = config->image_cy;
int mode = config->image_mode;
int quality = config->image_quality;
// reading width and height from the mount point (if exists)
int index = system->mounts.MountParImageSize();
if( m && m->param[index].defined && m->param[index].arg.size() == 2 )
{
cx = Tol(m->param[index].arg[0]);
cy = Tol(m->param[index].arg[1]);
}
// reading image mode from the mount point (if exists)
index = system->mounts.MountParImageMode();
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
mode = Toi(m->param[index].arg[0]);
// reading image quality from the mount point (if exists)
index = system->mounts.MountParImageQuality();
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
quality = Toi(m->param[index].arg[0]);
system->image.Resize(item, cx, cy, mode, quality);
Image::Scale scale = system->image.GetImageScale(item.parent_id);
system->image.Resize(item.id, scale.cx, scale.cy, scale.aspect_mode, scale.quality);
}
void Upload::CreateThumb(Item & item)
{
::Mount * m = system->mounts.CalcMount(item.parent_id);
size_t cx = config->thumb_cx;
size_t cy = config->thumb_cy;
int mode = config->thumb_mode;
int quality = config->thumb_quality;
// reading width and height from the mount point (if exists)
int index = system->mounts.MountParThumbSize();
if( m && m->param[index].defined && m->param[index].arg.size() == 2 )
{
cx = Tol(m->param[index].arg[0]);
cy = Tol(m->param[index].arg[1]);
}
// reading thumb mode from the mount point (if exists)
index = system->mounts.MountParThumbMode();
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
mode = Toi(m->param[index].arg[0]);
// reading image quality from the mount point (if exists)
index = system->mounts.MountParThumbQuality();
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
quality = Toi(m->param[index].arg[0]);
system->image.CreateThumb(item, cx, cy, mode, quality);
Image::Scale scale = system->image.GetThumbScale(item.parent_id);
system->image.CreateThumb(item.id, scale.cx, scale.cy, scale.aspect_mode, scale.quality);
}