CodeIgniter Forums
access to a function in gdlib - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: access to a function in gdlib (/showthread.php?tid=19345)



access to a function in gdlib - El Forum - 06-04-2009

[eluser]hht1230[/eluser]
The following works in a file outside CI:

$im = imagecreatefromjpeg('IMG_4025.jpg');
echo 'width=' . imagesx($im) . ' height=' . imagesy($im);

If I put it in a CI view file, I get

Message: imagecreatefromjpeg() [function.imagecreatefromjpeg]: URL file-access is disabled in the server configuration

What do I need to change / set to access imagecreatefromjpeg from inside CI?

thx,
Helen


access to a function in gdlib - El Forum - 06-04-2009

[eluser]Evil Wizard[/eluser]
I use imagecreatefromjpeg() in an image library inside CI and it works. Although from the snippet it seems you are only creating the image to get the height and widths of the image, would getimagesize() not be a less resource intensive way of achieving the same result?
Code:
$arrImageDetails = getimagesize($strSourceImageFile);
list($intSourceImageWidth, $intSourceImageHeight, $intSourceMimeType, $arrImageAttribs) = $arrImageDetails;



access to a function in gdlib - El Forum - 06-04-2009

[eluser]hht1230[/eluser]
Thanks. Both getimagesize and list are good to know about. But of course, using getimagesize I get the same error on that that I got previously on imagecreatefromjpeg - "URL file-access is disabled in the server configuration".

There must be a setting I need to specify somewhere to avoid that.


access to a function in gdlib - El Forum - 06-04-2009

[eluser]hht1230[/eluser]
Not sure if this is correct usage, but the image manipulation lib seemed to work fine for this:

in controller:
$config['image_library'] = 'gd2';
$this->load->library('image_lib', $config);

in view:
$im = $this->image_lib->image_create_gd($photopath . $pic['picfile'], 2);

// now width is available via imagesx($im)


access to a function in gdlib - El Forum - 06-05-2009

[eluser]appleifreak[/eluser]
I know that CI has an image library to do this kind of stuff, but none of it works for me either. I wonder if there is something we are missing in either the server configuration or .htaccess or maybe a weird setting in CI?


access to a function in gdlib - El Forum - 06-05-2009

[eluser]hht1230[/eluser]
The image manipulation library DID work for me. I looked in the class file (libraries/Image_lib.php) and found a function (image_create_gd; don't think it was in the docs) that allowed me to get the size of an image (though there may be an easier way to do that). What I couldn't get to work was trying to access gdlib functions directly from within a view file instead of using that built-in library.