Welcome Guest, Not a member yet? Register   Sign In
Image cropping problem
#1

[eluser]Unknown[/eluser]
I am trying to create media library that allows the user to upload a file and if they wish crop the image to there desired size. The actually cropping I am hoping to do via ajax (is this possible), basically they select select there crop area, and click crop the image is then processed and anew image is return them, all without a page reload.

However I am getting the following error,

Quote:Your server does not support the GD function required to process this type of image.

Now I know that I have GD installed, as you can see from my GD_INFO() dump.

Code:
array(11) { ["GD Version"]=> string(27) "bundled (2.0.34 compatible)" ["FreeType Support"]=> bool(false) ["T1Lib Support"]=> bool(false) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPEG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(false) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) }

I know that sometimes you see this message if CI cannot find the image, however when I run the following I get returned TRUE,

Code:
die(var_dump(file_exists($config['source_image'])));

Here is the full code I am working with,

Code:
$this->data['image'] = "Screen_shot_2012-01-05_at_16.19_.46_3.png";
if($this->input->post('crop_image') == "Crop") {
   $config['image_library'] = 'gd2';
   $config['source_image'] = "./media/images/products/".$this->data['image'];
   $config['maintain_ratio'] = FALSE;
   $config['x_axis'] = $this->input->post('x');
   $config['y_axis'] = $this->input->post('y');
   $config['width'] = $this->input->post('w');
   $config['height'] = $this->input->post('h');
   $config['dynamic_output'] = FALSE;
   $config['create_thumb'] = TRUE;
   $this->load->library('image_lib');
   $this->image_lib->initialize($config);
  
   if(!$this->image_lib->crop()) {
    if($this->input->post('isAjax') == "1") {
     echo json_encode($this->image_lib->display_errors());
    } else {
     die($this->image_lib->display_errors());
     $this->data['image_error'] = $this->image_lib->display_errors();
     $this->template->build('/admin/media/crop', $this->data);
    }  
   } else {
    $filename = base_url()."media/images/products/".$this->data['image'];
    $extension_pos = strrpos($filename, '.'); // find position of the last dot, so where the extension starts
    $thumb = substr($filename, 0, $extension_pos) . '_thumb' . substr($filename, $extension_pos);
    if($this->input->post('isAjax') == 1) {
     echo json_encode($success = array('message' => 'Image Cropped'));
    } else {
     $this->data['success'] = "Image Cropped";
     $this->template->build('/admin/media/crop', $this->data);
    }
   }

Is there a problem that I am overlooking, I know that I am trying to process this using ajax, however I have also tried to process it as a normal request and get the exact same error.
#2

[eluser]Jason Stanley[/eluser]
Is your png a valid png? What happens if you remove the additional dots from the file name?

You asked about ajax cropping. I have used this in the past. Its a nice bit of kit.
http://deepliquid.com/content/Jcrop.html
#3

[eluser]Unknown[/eluser]
Thanks for the reply, PNG is valid, tried it with a totally different image (and filetype) and still the same problem.

Your right jCrop is awesome it is what I am using to give the user the cropping interface.




Theme © iAndrew 2016 - Forum software by © MyBB