The class Simple Image does not work normally when I call it through CRON. Works fine only when the call goes through the browser.
$image = new SimpleImage(); $image ->load($path); $format_avatar = explode(".", $path); $name_photo = md5(microtime() . $postId). '.' . $format_avatar[count($format_avatar) - 1]; $uploaddir_big = $_SERVER['DOCUMENT_ROOT'] . '/site.com/images/big/'; $image -> save($uploaddir_big . $name_photo) // = true, но файлов не обнаруженно
Some functions from the class Simple Image
function load($filename) { $image_info = getimagesize($filename); $this->image_type = $image_info[2]; if( $this->image_type == IMAGETYPE_JPEG ) { $this->image = imagecreatefromjpeg($filename); } elseif( $this->image_type == IMAGETYPE_GIF ) { $this->image = imagecreatefromgif($filename); } elseif( $this->image_type == IMAGETYPE_PNG ) { $this->image = imagecreatefrompng($filename); } } function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image,$filename,$compression); return 'true'; } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image,$filename); return 'true'; } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image,$filename); return 'true'; } if( $permissions != null) { chmod($filename,$permissions); }
}
Gives an error message
Warning: imagejpeg () [function.imagejpeg]: Unable to open 'site.com/images/big/dfa47b99317704b23660e09de5604dd4.jpg' for writing: No such file or directory .php
$uploaddir_big = $_SERVER['DOCUMENT_ROOT']
cron doesn't know anything about this. somehow differently specify the site directory. - zb '