views:

7

answers:

1

Hi, createThumb() method working with localhost on apache server.But, the same function not working with Amazon EC2. Which is showing an error like,

exception 'Engine_Exception' with message 'Method "createThumb" not supported' in /var/www/justrides/application/modules/Core/Api/Abstract.php:46

GD Library enabled in the server. Any suggections please.

A: 

Here is what I found on Amazon's website:

function createthumb($name,$filename,$new_w,$new_h){
      $system=explode('.',$name);
      if (preg_match('/jpg|jpeg/',$system[1])){
           $src_img=imagecreatefromjpeg($name);
      }
      if (preg_match('/png/',$system[1])){
           $src_img=imagecreatefrompng($name);
      }
      $old_x=imageSX($src_img);
      $old_y=imageSY($src_img);
      if ($old_x > $old_y) {
           $thumb_w=$new_w;
           $thumb_h=$old_y*($new_h/$old_x);
      }
      if ($old_x < $old_y) {
           $thumb_w=$old_x*($new_w/$old_y);
           $thumb_h=$new_h;
      }
      if ($old_x == $old_y) {
           $thumb_w=$new_w;
           $thumb_h=$new_h;
      }
      $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
      imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
      if (preg_match("/png/",$system[1])){
           imagepng($dst_img,$filename); 
      } else {
           imagejpeg($dst_img,$filename); 
      }
      imagedestroy($dst_img); 
      imagedestroy($src_img); 
 }

The createthumb() function is a simple function that takes four arguments: file to process, output file name, width of output file, and height of output file. The function makes use of GD image-manipulation tools and is adapted from Christian Heilmann’s function available at http://icant.co.uk/articles/phpthumbnails/.

Here is another thumbnail library: http://phpthumb.sourceforge.net/

infinity
Thank you so much. I am using the same function. But it not works with mentioned server. Only one difference was GD Version 2.0 or higher in local server but in EC2 it is GD Version 2.0. Any problem for this difference.
Ajith