Welcome Guest, Not a member yet? Register   Sign In
GD2/image_lib working on live website, but not on localhost (XAMPP)
#1

[eluser]shadowmanwkp[/eluser]
Hi there, I've been scouring the internet for an answer, but I just can't seem to find one. My problem is with a controller that uses img_lib's resize function. There's an existing website I'm working on that displays the images that go through img_lib properly, but when I look at them through localhost, they show up as broken images. If I use <img> tags to point directly to the images they work absolutely fine, only the images that get go through the controller get broken.

Here's the code:

Code:
function resized() {
  $irrelevant_part_of_uri = "/images/resized/" . $this->uri->segment(3) . "/" . $this->uri->segment(4) . "/";
  $image_path = substr(uri_string(), strlen($irrelevant_part_of_uri));
  //$image_dimensions = getimagesize("public/" . $image_path);

   $config['image_library'] = 'gd2';
   $config['source_image'] = "public/" . $image_path;
   $config['create_thumb'] = FALSE;
   $config['maintain_ratio'] = TRUE;
   $config['width'] = $this->uri->segment(3);
   $config['height'] = $this->uri->segment(4);
   $config['dynamic_output'] = TRUE;
   $config['quality'] = 100;
   $this->load->library('image_lib', $config);
   $this->image_lib->resize();
}


Because the dev that made the website is gone, and I have no documentation, it took me a while to figure out the code:

- There's a controller images.php with the function resized()
- The images already exist and reside in <domain>/public/userfiles/images and its subfolders
- The image paths are pulled from a database, which I have running locally. These paths are put into <img> tags in their respective views
- I have no clue why 'public/' is concatenated in source_image, the dev might as well have put that part of the path in the database
- All images that need to be resized have the following urls <domain>/images/resized/<width><height>/actual/path/to/file.jpg
- The function looks at <width> and <height> and uses uri->segment in order to see the dimensions that need to be resized to
- Because dynamic_output is on, there's no actual folder that points to the image, but you can fool the <img> tags so you do display an image (just stick them in the folder hierarchy the src attribute specifies)
- It does not matter if I autoload image_lib, and call it through a different function (forgot the specifics...): I still get thrown an error
- According to netbeans, $image_dimensions wasn't used anywhere, so I commented it out, didn't seem to affect anything

Here's some more info using a non-existing image (if I use an existing one, the browser throws an error message because the image is broken):

Example URL:
http://<local domain>/images/resized/150/300/userfiles/images/products/asdf.jpg

Code:
echo $irrelevant_part_of_uri: /images/resized/150/300/
echo $image_path: userfiles/images/products/asdf.jpg
echo $this->image_lib->display_errors():
The path to the image is not correct.

Your server does not support the GD function required to process this type of image.

print_r($config):

Array
(
    [image_library] => GD2
    [source_image] => public/userfiles/images/products/asdf.jpg
    [create_thumb] =>
    [maintain_ratio] => 1
    [width] => 150
    [height] => 300
    [dynamic_output] => 1
    [quality] => 100
)

print_r(gd_info()):

Array
(
    [GD Version] => bundled (2.1.0 compatible)
    [FreeType Support] => 1
    [FreeType Linkage] => with freetype
    [T1Lib Support] =>
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPEG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] => 1
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] =>
)

phpinfo():

Core

PHP Version  5.5.11
max_execution_time 600
max_file_uploads 20
max_input_nesting_level  64
max_input_time 300
max_input_vars 1000
memory_limit 128M
output_buffering 4096
post_max_size  50000M
precision 14
realpath_cache_size 16k
upload_max_filesize 2000M

gd

GD Support  enabled
GD Version  bundled (2.1.0 compatible)
FreeType Support  enabled
FreeType Linkage  with freetype
FreeType Version  2.4.10
GIF Read Support  enabled
GIF Create Support  enabled
JPEG Support  enabled
libJPEG Version  9 compatible
PNG Support  enabled
libPNG Version  1.5.18
WBMP Support  enabled
XPM Support  enabled
libXpm Version  30411
XBM Support  enabled
WebP Support  enabled

And for good measure my operating system and software versions:

OS: Windows 8 pro - 64-bit
XAMPP 1.8.3
Codeigniter version: 1.7.3

Any help would be greatly appreciated!


Messages In This Thread
GD2/image_lib working on live website, but not on localhost (XAMPP) - by El Forum - 08-29-2014, 01:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB