EllisLab text mark
Advanced Search
     
Once again image resizing :/ Need help!
Posted: 04 July 2007 11:02 AM   [ Ignore ]
Joined: 2007-04-06
67 posts

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

$this->image_lib->clear();
$image_config["source_image"$image;
$image_config["maintain_ratio"true;
$image_config['width'400;
$image_config['height'600;
$this->image_lib->initialize($image_config);
$this->image_lib->resize() 

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? :(

 Signature 

My Celebrity Blog, My Magento Blog

 
Posted: 04 July 2007 11:33 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-08-06
918 posts

“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. wink

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

 
Posted: 04 July 2007 11:40 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2007-04-06
67 posts

Thanx, for reply wink
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 :/

 Signature 

My Celebrity Blog, My Magento Blog

 
Posted: 04 July 2007 12:13 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2006-10-02
332 posts

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.

 Signature 

Dotted line.

 
Posted: 04 July 2007 02:30 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2007-04-06
67 posts

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 wink

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

 Signature 

My Celebrity Blog, My Magento Blog

 
Posted: 04 July 2007 09:43 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2006-08-06
918 posts

no problem! happy you are happy. grin 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.!”

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

 
Posted: 05 July 2007 03:37 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2007-04-06
67 posts

:-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 wink but thanks for your corrections, it made me smile smile

 Signature 

My Celebrity Blog, My Magento Blog

 
Posted: 05 July 2007 04:39 AM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Joined: 2006-10-02
332 posts

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? wink

 Signature 

Dotted line.

 
Posted: 05 July 2007 08:31 AM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Joined: 2007-04-06
67 posts

who’s doing nothing? (think)

 Signature 

My Celebrity Blog, My Magento Blog