Welcome Guest, Not a member yet? Register   Sign In
image resizing, multiple problems
#1

[eluser]smickiedoo[/eluser]
Hello again guys,

I'm having problems with image resizing in CI. My most significant problem is that it seems that if my image is larger than 1024x768 the images are not resized and I get blank white pages, or rather my view files do not load. My files are being uploaded to the server, and if I comment out the resize call it works, but with large images it just gives white pages. Is this a known issue? I've tried the code on several different servers, and I've tried it with DG and DG2 with no luck. I do not have ImageMagick installed to try.

Another issue I'm having is if I do multiple file resizing it processes the first image correctly, but the second renders as black with a tiny little image in the corner. Any images processed after this are black.

I have tried writting the code several different ways. I've tried doing all processing in one function and I've tried writing a dedicated function which gets called and not called again until it returns true, but it always gives the same results. Any help with this would be a godsend. This functionality was due on the site I'm working on a week ago.

Thanks,
Nathan
#2

[eluser]smickiedoo[/eluser]
Nobody knows anything about this? I'm sure it's not my code because I've tried it several different ways on several different servers. Is there a preferred way to resize images outside of CI? Thanks again for any help.

Nathan
#3

[eluser]TheFuzzy0ne[/eluser]
[quote author="smickiedoo" date="1234160337"]I'm having problems with image resizing in CI. My most significant problem is that it seems that if my image is larger than 1024x768 the images are not resized and I get blank white pages, or rather my view files do not load. My files are being uploaded to the server, and if I comment out the resize call it works, but with large images it just gives white pages. Is this a known issue? I've tried the code on several different servers, and I've tried it with DG and DG2 with no luck. I do not have ImageMagick installed to try.[/quote]

The only thing I can think of is that you might be exceeding the PHP memory limit. How large is the image you're uploading?

[quote author="smickiedoo" date="1234160337"]Another issue I'm having is if I do multiple file resizing it processes the first image correctly, but the second renders as black with a tiny little image in the corner. Any images processed after this are black.[/quote]

Are you calling $this->image_lib->clear() between processing each image?
#4

[eluser]SitesByJoe[/eluser]
You should also post some code for review.
#5

[eluser]simshaun[/eluser]
FuzzyOne is correct. I'm about 99.9% sure its because of your memory limit.
Here's a script to estimate the amount of memory you'll need for an image (in bytes).
Code:
$image_info = getimagesize($image_src);
$image_width = $image_info[0];
$image_height = $image_info[1];
$image_bits = $image_info['bits'];
$image_channels = $image_info['channels'];
$memory_needed = round(($image_width * $image_height * $image_bits * $image_channels / 8 + Pow(2, 16)) * 1.8);
echo $memory_needed;
#6

[eluser]TheFuzzy0ne[/eluser]
Awesome script! I never even knew that was possible. Impressive stuff!
#7

[eluser]Skinnpenal[/eluser]
[quote author="TheFuzzy0ne" date="1234253829"]Awesome script! I never even knew that was possible. Impressive stuff![/quote]

I second that! So now one could easily raise the memory limit temporarely with ini_set, but how bad would it be doing so? I guess it increases the chance of the server being too busy. I also remember reading somewhere that it's "insecure" to have too high of a memory limit, can't exactly remember why, but something about letting certain attacks run too far, though I guess this wouldn't be as big of an issue when only doing so temporarely.

Memory- / resource-wise, is ImageMagick a better choice than GD for this kind of stuff?
#8

[eluser]simshaun[/eluser]
ImageMagick has support for more image formats, and performs better in most cases.
Not only that, but IIRC you don't have to worry so much about memory with it because it doesn't use PHP's memory. Another advantage is that downsized images are a bit sharper with ImageMagick than they are with GD.

ImageMagick does have its disadvantages to GD though.
One example is when you are doing a batch-add. GD will work on each image one at a time, whereas ImageMagick will start up a separate process for each image all at once, possibly bogging the server down.

I see no reason to use ImageMagick unless you need the additional features or want to worry less about memory.
#9

[eluser]eltrutgnik[/eluser]
Sorry for bring up an old thread, but im having the same problem as the original poster.

I've ran the script that the above poster posted and changed my memory limit. After changing my memory limit i still get the same error.




Theme © iAndrew 2016 - Forum software by © MyBB