我应该在单独的文件夹joomla中为imagecreatefrompng提供什么路径?

I've been trying to make use of the function imagecreatefrompng in joomla. Iam using that function inside components/mycomponent/views/imgview/tmpl/default.php I have to pass the image url administrator/components/mycomponent/images/img.png into it.

I've tried many ways. But none of it is working. Is there any specific way to pass the url to that function. ie. should I pass it as

$img = imagecreatefrompng('administrator/components/mycomponent/images/img.png');

or

$img = imagecreatefrompng('http://localhost/joomla/administrator/components/mycomponent/images/img.png');

or

$img = imagecreatefrompng('/var/www/joomla/administrator/components/mycomponent/images/img.png');

any help would be greatly appreciated.

If you look at some of the default template files, Joomla typically prefers you to make use of the JPATH_ROOT global variable to make sure you're always working from the site root, like so:

$path = JPATH_ROOT . '/administrator/components/mycomponent/images/img.png';  
$img = imagecreatefrompng($path);

EDIT: Forgot the first slash.