CodeIgniter Forums
Image Library is not saving image - 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: Image Library is not saving image (/showthread.php?tid=56759)



Image Library is not saving image - El Forum - 01-17-2013

[eluser]Patrick Reck[/eluser]
I am trying to fetch a picture of a bear from the URL and save it as aabear.jpg. However, my code is failing. What is wrong?


Code:
$config['image_library'] = 'gd2';
$config['source_image'] = 'http://thejuxtapositionape.blog.com/files/2012/03/polar-bear-pup.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width']  = 75;
$config['height'] = 50;
$config['new_image'] = 'aabear.jpg';

$this->load->library('image_lib', $config);



Image Library is not saving image - El Forum - 01-17-2013

[eluser]CroNiX[/eluser]
You're just loading the library, but not telling it to do anything. Also not sure if source_image can be a URL, the manual refers to a local path.


Image Library is not saving image - El Forum - 01-17-2013

[eluser]Patrick Reck[/eluser]
[quote author="CroNiX" date="1358461930"]You're just loading the library, but not telling it to do anything. Also not sure if source_image can be a URL, the manual refers to a local path.[/quote]

It worked using local path. Thank you


Image Library is not saving image - El Forum - 01-17-2013

[eluser]CroNiX[/eluser]
If all you are trying to do is retrieve an image from a URL and save it on your local filesystem, I'd use file_get_contents(), and then file_put_contents(). The image library is for manipulation, like cropping, resizing, rotating, watermarking, etc.