• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Once again image resizing :/ Need help!

i dont understand, why image_lib expands the image to the specified width and height parameters if there is parameter maintain_ratio = TRUE ??

$image_config["source_image"] = $image;
$image_config["maintain_ratio"] = true;
$image_config['width'] = 400;
$image_config['height'] = 600;

i need that if an image which is smaller than specified width and height (in my case 400x600) it would remain NOT resized. Resize for me is needed only in case an image is bigger in width or height than 400x600. Whats wrong with my so simple code? Maybe I dont understand what "maintain_ratio" means? Sad

"maintain ratio" refers to keeping the resized width and height in the same relationship as they were in the original; it does not address your specific concern: the image is resizing larger as well as smaller.

to fix your problem, i suggest you look at the image_lib code and see if you can spot what is going on that is making the image grow as well as shrink. maybe you are sending it too many config parameters?

note, i have done only a little work using this library so you can ask me further questions and i will go look at the source or you can look at the source yourself and discover the root of the problem... whichever you prefer. ;-)

Thanx, for reply ;-)
I dont send too many config parameters. I send only these that i provided in the code above. For all remaining parameters values are not set (defaults).
My head aches :/ tried various config parameters values variations but havent achieved any positive result :/

It seems you are confusing the issues.

The image manipulation class only manipulates the image.

You want to check if the image, uploaded or already on the server, is a certain size and based on that size, it is either manipulated, resized, or not.

That's two different tasks.

First, determine the dimensions of your image using either the upload data array in the CI upload class or a PHP function, getimagesize().

Now you have the width and height of the image. Then write a conditional that sends it to the resize function or not, if < 400 x 600.

Maybe you are right crimp, but i always thought and still think that this task should be an image manipulation library's issue.. Ok, I understood, lets close this thread ;-)

p.s. CI ownz! it speeded my project develepment a lot, thank you all guys!

no problem! happy you are happy. :-) i agree that this should be at least a preference to tell the resize function to only shrink and not grow. it may be in there already, but you'd have to look into the source to see.

BTW, in english the phrase would be: "it speeded my project development" (not fastened - "fastened" means "attached, tightly" as in "i fastened my seatbelt" or "the ironworker fastened the rivet") or you could say "accelerated my proj. dev." or to be right in tune with CI you could say "it lit a fire under my proj. dev.!"

:-D sophistry you are absolutely right, i knew it but forgotten, you see I'm from Lithuania and to write or to talk in english i need really rarely. Usually I only read ;-) but thanks for your corrections, it made me smile Smile

There is a secret in there. But, as it says in the comments, it will be our little CI secret. It returns TRUE. It's close to what you are looking for, but not quite. When would it return TRUE without doing anything? ;-)

who's doing nothing? (think)

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.