I have an image that is uploaded to the server, I then get the image information and resize using imagick, this works great on my local server (xammp) but when I upload to site to godaddy, only certain images load. Here is a snippet of code;
$image = frameEngine($_FILES['myFile']['tmp_name'];
$tempHeight = $image->getHeight();
$tempWidth = $image->getWidth();
$inches = $image->getInches();
In the class frameEngine it reads;
Class frameEngine {
private $image;
private $height;
private $width;
private $dpi;
function __construct($file) {
$this->image = new Imagick(realpath($file));
$this->width = $this->image->getImageWidth();
$this->height = $this->image->getImageHeight();
$this->dpi = $this->image->getImageResolution();
}
public function getHeight() {
return $this->height;
}
public function getWidth() {
return $this->width;
}
public function getInches() {
$dpi = $this->dpi;
$iw = round(($this->width / $dpi['x']*100)/100,2);
$ih = round(($this->height / $dpi['y']*100)/100,2);
return array('w' => $iw, 'h' => $ih);
}
}
I get a division by zero error in getInches() obviously because Imagick is returning 0 as image height and width, therefore I believe imagick is failing on the image. The image is obviously fine as it works on my local server.
Two things before you come to the conclusion that Imagick is not working
Make a test script and use phpinfo()
. Hit the page from your browser and look for imagick mentioned in that page. If this is not mentioned then boom! you need to contact your hosting provider for this
Secondly, make sure that file upload is enabled and file is uploaded properly by using old-school var_dump
Hope this helps fella!