Today i found out, that since release "snapshot 2007-10-12" (1.3.5) it's possible to crop images in the Contentpart "images <div>".
I was really happy about that (Thanx Oli) but missed a feature, that would make this functionality a bit more fiting for me:
To tell phpwcms how much of the image should be croped
So i looked up the code, made some changes and got it to work:
After changing 3 things in 2 files of the core it is possible to use this RP-Tag in the caption of each image:
{POS
(x and y are the pixels that are croped on the image and also may be "center")
In the Frontend it looks like this:
http://www.netzelf.de/index.php?aid=3&pg=3
In the Backend it looks like this:

So what is to do to get this working?
Open include/inc_lib/imagick.convert.inc.php and find:
Code: Select all
$default = array(
"max_width" => $GLOBALS['phpwcms']["img_list_width"],
"max_height" => $GLOBALS['phpwcms']["img_list_height"],
"image_dir" => PHPWCMS_ROOT . '/' . PHPWCMS_FILES,
"thumb_dir" => PHPWCMS_ROOT . '/' . PHPWCMS_IMAGES,
'jpg_quality' => $GLOBALS['phpwcms']['jpg_quality'],
'sharpen_level' => $GLOBALS['phpwcms']['sharpen_level'],
'crop_image' => false
Code: Select all
,
'crop_x' => false, //Added for positioned croping
'crop_y' => false //Added for positioned croping
Code: Select all
$crop_x = abs( $image->get_w() - $imagick["max_width"] );
$crop_x = ceil( $crop_x / 2 );
$crop_y = abs( $image->get_h() - $imagick["max_height"] );
$crop_y = ceil( $crop_y / 2 );
Code: Select all
//Added for positioned croping
if ($imagick['crop_x'] != false && $imagick['crop_y'] != false) {
$crop_x = ($imagick['crop_x'] != "center") ? $imagick['crop_x'] : $crop_x;
$crop_y = ($imagick['crop_y'] != "center") ? $imagick['crop_y'] : $crop_y;
}
//End of Changes for positioned croping
Code: Select all
$thumb_image = get_cached_image(
array( "target_ext" => $image['images'][$key][3],
"image_name" => $image['images'][$key][2] . '.' . $image['images'][$key][3],
"max_width" => $image['images'][$key][4],
"max_height" => $image['images'][$key][5],
"thumb_name" => md5( $image['images'][$key][2].$image['images'][$key][4].
$image['images'][$key][5].$phpwcms["sharpen_level"].
$image['crop']
),
'crop_image' => $image['crop']
)
);
Code: Select all
//Add position for croping images (by netzelf)
$img_thumb_vars = array( "target_ext" => $image['images'][$key][3],
"image_name" => $image['images'][$key][2] . '.' . $image['images'][$key][3],
"max_width" => $image['images'][$key][4],
"max_height" => $image['images'][$key][5],
"thumb_name" => md5( $image['images'][$key][2].$image['images'][$key][4].
$image['images'][$key][5].$phpwcms["sharpen_level"].
$image['crop']
),
'crop_image' => $image['crop'] );
preg_match('/\{POS:(.+?):(.+?)\}/is', $image['images'][$key][6], $img_pos);
$image['images'][$key][6] = preg_replace('/\{POS:(.+?):(.+?)\}/is', "", $image['images'][$key][6]);
if (!empty($img_pos[1]) && !empty($img_pos[2])) {
$img_thumb_vars["crop_x"] = $img_pos[1];
$img_thumb_vars["crop_y"] = $img_pos[2];
$img_thumb_vars["thumb_name"] = md5( $image['images'][$key][2].$image['images'][$key][4].
$image['images'][$key][5].$phpwcms["sharpen_level"].
$image['crop'].$img_pos[1].$img_pos[2]
);
}
$thumb_image = get_cached_image($img_thumb_vars);
//End of changes for positioned croping
Hope you will like this as much as me
