Welcome Guest, Not a member yet? Register   Sign In
GD library
#11

[eluser]xwero[/eluser]
try this code (from php.net)
Code:
function LoadJpeg($imgname)
{
    $im = @imagecreatefromjpeg($imgname); /* Attempt to open */
    if (!$im) { /* See if it failed */
        $im  = imagecreatetruecolor(150, 30); /* Create a black image */
        $bgc = imagecolorallocate($im, 255, 255, 255);
        $tc  = imagecolorallocate($im, 0, 0, 0);
        imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
        /* Output an errmsg */
        imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
    }
    return $im;
}
header("Content-Type: image/jpeg");
$img = LoadJpeg("bogus.image");
imagejpeg($img);
If that doesn't work there is something wrong with the configuration on the server somewhere else there is a bug in the image_lib library
#12

[eluser]Fatih[/eluser]
Ok. It is done. My image path was wrong.

Code:
$config['source_image'] = '/home/sevenly/public_html/ci/images/avatars/'.$this->upload->data('file_name');

I repaired this link and the problem solved.

Thank you for all.
#13

[eluser]ardinotow[/eluser]
Code:
$config['source_image'] = '/home/sevenly/public_html/ci/images/avatars/'.$this->upload->data('file_name');

@fatigue. I also have the same problem. How to know the path of my htdocs folder on server like you provided above? thanks...
#14

[eluser]Fatih[/eluser]
Hello ardinotov.

If you use any simple ftp program (like as filezilla), you can find the right path on "remote site" box which your files storage on your server. Generally, if you use a apache server, your path should be :

Code:
/home/[username]/public_html/[installed ci]/[storage files]/

But, my file names were wrong in my case.
#15

[eluser]Tom Glover[/eluser]
[quote author="ardinotow" date="1207593689"]
Code:
$config['source_image'] = '/home/sevenly/public_html/ci/images/avatars/'.$this->upload->data('file_name');

@fatigue. I also have the same problem. How to know the path of my htdocs folder on server like you provided above? thanks...[/quote]

This has fixed my problem as well. Well I knew the htdocs folder.
#16

[eluser]ardinotow[/eluser]
Code:
$config['source_image'] = '/home/sevenly/public_html/ci/images/avatars/'.$this->upload->data('file_name');

If I try on local server how that path should be? I have tried these source image path below and I still got the same error message 'Your server does not support the GD function required to process this type of image'
1.
Code:
$config['source_image'] = 'G:\apache2triad\htdocs\advoria-ci-FA\advoria-assets\logo\'.$filename

2.
Code:
$config['source_image'] = '\advoria-assets\logo\'.$filename

And, the other config are:
Code:
$config['image_library'] = 'GD2';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 75;

FYI, I use windows and apache2triad server environment. According to phpinfo, GD version is 2.0.28
#17

[eluser]brownkow[/eluser]
Somebody correct me if I am wrong, but...

You *could* just use the built-in php reserved variable of $_SERVER['DOCUMENT_ROOT']. This variable is set to the root directory of the site.

http://uk2.php.net/reserved.variables
#18

[eluser]ardinotow[/eluser]
Thanks brownkow....my problem has solved :cheese:

I use this pattern to configure image source

Code:
$config['source_image'] = $_SERVER['DOCUMENT_ROOT'].'/advoria-ci-FA/'.$data['path_pic'].$filename;

There are 4 segments in that pattern and here is the explanation:

1.
Code:
$_SERVER['DOCUMENT_ROOT']
will produce
Code:
G:/apache2triad/htdocs
on my local/home server.

2.
Code:
/advoria-ci-FA/
is the root folder for all my application. If you put your application in htdocs then you can delete this segment.

3.
Code:
$data['path_pic']
is my variable containing path-to-image data. Instead of using variable you can directly put your folder name, i.e: myassets/upload/.

4.
Code:
$filename
is my variable for image file name, i.e: myimage.jpg.

After you have declared all configuration don't forget to add this code:
Code:
$this->load->library('image_lib', $config);
$this->image_lib->initialize($config);



So, my complete creating thumbnail code is:

Code:
$this->load->library('image_lib');
            
$config['image_library'] = 'GD2';
$config['source_image'] = $_SERVER['DOCUMENT_ROOT'].'/advoria-ci-FA/'.$data['path_pic'].$filename;
$config['new_image'] = $_SERVER['DOCUMENT_ROOT'].'/advoria-ci-FA/'.$data['path_pic'].'thumbs/'.$filename;
$config['thumb_marker'] = '';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['master_dim'] = 'width';
$config['width'] = 75;
$config['height'] = 75;

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

That's all, hope this little info can help someone :cheese:
#19

[eluser]brownkow[/eluser]
Glad you got it working.

I'm sure your code will help someone, I just hope we haven't thrown anybody off the CI path, because I would not be surprised if there was a CI equivalent.




Theme © iAndrew 2016 - Forum software by © MyBB