Welcome Guest, Not a member yet? Register   Sign In
Resize only if bigger
#1

[eluser]Kamape[/eluser]
Hi!

I want to resize an image ONLY if the image is bigger than the constraints. Is this possible? As it is now the small pictures get's resized bigger and that's not the purpose for me.

Thanks in advance
#2

[eluser]Kamape[/eluser]
Nevermind, used getimagesize() instead to decide operation.

But if there's anything built in CI please post this.
#3

[eluser]stuart_g[/eluser]
I don't use the CI functions for image resizing, but instead just upload the fullsize images and then display using phpThumb and let that handle the resizing on my behalf. It has the option to only resize if bigger than constraints.

http://phpthumb.sourceforge.net/
#4

[eluser]Kamape[/eluser]
Thanks for the suggestion, but I'm currently uploading an image, then resizing if bigger than 640x480 AND creating a thumb. Theese two I'm binary saving into the database and then deleting the files onto disk.

Maybe phpThumb can accomplish reading like that anyway, I'll better try that of for my next project.

Thanks!
#5

[eluser]pistolPete[/eluser]
[quote author="Kamape" date="1254930406"]Nevermind, used getimagesize() instead to decide operation.

But if there's anything built in CI please post this.[/quote]

If you use the upload class, you automatically get the image dimensions:

Quote:$this->upload->data()
This is a helper function that returns an array containing all of the data related to the file you uploaded.
Code:
Array
(
    [file_name]    => mypic.jpg
    [file_type]    => image/jpeg
  ...
    [is_image]     => 1
    [image_width]  => 800
    [image_height] => 600
    [image_type]   => jpeg
    [image_size_str] => width="800" height="200"
)
#6

[eluser]Kamape[/eluser]
Yes, that's a great way to determine the width and height before eventual resizing.

Thanks!
#7

[eluser]BrianDHall[/eluser]
[quote author="Kamape" date="1254940714"]Yes, that's a great way to determine the width and height before eventual resizing.

Thanks![/quote]

Its also a nice way to save a redundant call to getimagesize, because that's how the upload class gets the info Smile




Theme © iAndrew 2016 - Forum software by © MyBB