简体   繁体   English

图像处理-如何保存原稿,调整大小并保存在文件夹A中,如何制作缩略图并保存在文件夹B中

[英]Image Manipulation - How do I save original, resize & save in folder A and make thumbnail & save in folder B

I've just started using the Image Manipulation Class, and I can't seem to solve what I considered a simple task. 我刚刚开始使用Image Manipulation Class,但是似乎无法解决我认为简单的任务。 I have a image upload form. 我有一张图片上传表格。 The image is uploaded to ./assets/img/uploads/original/ as imgX.jpg . 图像被上传到./assets/img/uploads/original/imgX.jpg Then I store the full path to the image in $path and what I am trying to do next is to create a 32x50 thumbnail and store it in ./assets/img/uploads/covers-thumb/ (by default it is saved as imvx_thumb ) and to resize the imgX.jpg into 200x310 and store save it in ./assets/img/uploads/covers-big/ as imgX_cover . 然后,我将图像的完整路径存储在$path ,接下来我要做的是创建一个32x50缩略图,并将其存储在./assets/img/uploads/covers-thumb/ (默认情况下,它保存为imvx_thumb ),并将imgX.jpg大小调整为200x310然后将其保存为./assets/img/uploads/covers-big/作为imgX_cover

Right now I have one problem. 现在我有一个问题。 With the current code it's like the second resize does't even happen. 使用当前代码,就好像第二次调整大小都没有发生。 I only end up with imgX.jpg in the original folder and imgX_thumb.jpg in the covers-thumb folder. 我只结了imgX.jpgoriginal文件夹,并imgX_thumb.jpgcovers-thumb夹。 But I am missing the 200x310 imgX_cover in the covers-big folder. 但是我在200x310 covers-big文件夹中缺少200x310 imgX_cover Please take a look at the code below. 请看下面的代码。 I have added << as comment to the parts of the config that are changing. 我已将<<添加为正在更改的配置部分的注释。 I'm looking forward to your suggestions, thank you. 期待您的建议,谢谢。

$configI['image_library'] = 'gd2';
$configI['source_image']    = $path;
$configI['create_thumb'] = TRUE; // <<
$configI['maintain_ratio'] = FALSE;
$configI['width']    = 32; // <<
$configI['height']  = 50; // <<
$configI['new_image'] = './assets/img/uploads/covers-thumb/'; // <<     
$this->load->library('image_lib', $configI);
$this->image_lib->resize();

$this->image_lib->clear();

$configI['image_library'] = 'gd2';
$configI['source_image']    = $path;
$configI['create_thumb'] = TRUE; // <<
$configI['thumb_marker'] = "_cover"; // <<      
$configI['maintain_ratio'] = FALSE;
$configI['width']    = 200; // <<
$configI['height']  = 310; // <<
$configI['new_image'] = './assets/img/uploads/covers-big/'; // <<       
$this->load->library('image_lib', $configI);
$this->image_lib->resize();

Try 尝试

$this->load->library('image_lib'); 
$this->image_lib->initialize($configI);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM