|
@@ -159,7 +159,10 @@ class Qiniu extends Core implements Config
|
|
|
}
|
|
|
|
|
|
//?imageView2/2/w/360/h/270/format/png/q/75|imageslim
|
|
|
- $dest = $this->data['host'] . $source . '?imageView2/2/w/'.$config['width'].'/h/'.$config['height'];
|
|
|
+ if (!strstr($source, 'http')) {
|
|
|
+ $source = $this->data['host'] . $source;
|
|
|
+ }
|
|
|
+ $dest = $source . '?imageView2/2/w/'.$config['width'].'/h/'.$config['height'];
|
|
|
|
|
|
if (isset($config['compress']) && $config['compress'] > 0) {
|
|
|
$dest .= '/q/' . $config['compress'];
|
|
@@ -175,28 +178,32 @@ class Qiniu extends Core implements Config
|
|
|
*
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function handle_c($id, $source = false, $dest = false)
|
|
|
+ public function handle_c($id, $source = false, $dest = false, $path = '')
|
|
|
{
|
|
|
$config = Dever::load('upload/pic_crop-one', $id);
|
|
|
-
|
|
|
if ($config) {
|
|
|
|
|
|
if (!$source) {
|
|
|
$source = $this->output['file'];
|
|
|
}
|
|
|
|
|
|
- if (!$dest) {
|
|
|
- if (strpos($this->name, '_c') !== false) {
|
|
|
- $temp = explode('_c', $this->name);
|
|
|
- $this->name = $temp[0];
|
|
|
- }
|
|
|
- $this->name .= '_c' . $id;
|
|
|
- $dest = $this->file();
|
|
|
+ //?imageView2/2/w/360/h/270/format/png/q/75|imageslim
|
|
|
+ if (!strstr($source, 'http')) {
|
|
|
+ $source = $this->data['host'] . $source;
|
|
|
+ }
|
|
|
+ $temp = parse_url($source);
|
|
|
+ $file = ltrim($temp['path'], '/');
|
|
|
+ $file = Dever::db('upload/file')->one(array('file' => $file));
|
|
|
+
|
|
|
+ $x = $y = 0;
|
|
|
+ if ($file) {
|
|
|
+ list($x, $y) = $this->img()->get_position($file['width'], $file['height'], $config['width'], $config['height'], 'crop', $config['type']);
|
|
|
}
|
|
|
|
|
|
- $size = $config['width'] . '_' . $config['height'] . '_2';
|
|
|
+ $dest = $source . '?imageMogr2/crop/!'.$config['width'].'x'.$config['height'].'a'.$x.'a' . $y;
|
|
|
|
|
|
- $this->img()->crop($source, $size, false, true, $dest);
|
|
|
+ $dest .= '|imageslim';
|
|
|
}
|
|
|
+ return $dest;
|
|
|
}
|
|
|
}
|