janisto / ImageUtil

Easy resize, filter and compression class for images.
http://www.mikkonen.info/imageutil/
6 stars 0 forks source link

Resizing small images #2

Open boubouhkarim opened 10 years ago

boubouhkarim commented 10 years ago

hi, thanks for the really Utile Image, i really like you're work and i use it know. but if i resize i small image it take the new size, Normally it should keep it's size in order to not lose it's quality i hope you will include that.

janisto commented 10 years ago

What do you mean? Are you resizing a small image to a bigger size in pixels? If you don't want a bigger image, don't resize?

boubouhkarim commented 10 years ago

Eehh !! you know all peoples will use you're great class in automated scripts, right ! than all images bigger or smaller will be resized. in my script i added a new little function in you're class named allowResize() to do that! but i hope you can add something more smart, you know i just compare the old & new size. i hope you will understand what i was saying !


I'm sorry but i have an other suggestion (i like share what i know) : if a user has aploaded an image with wrong extension (for example x.png names y.jpg) you're class will fail to open the image because of imagecreatefromX functions so you should get the right extension from image using finfo function (i didn't do that yet !)

janisto commented 10 years ago

I guess you could also use it like this:

$resizeWidth = 640;
$resizeHeight = 480;
//$image = 'http://www.mikkonen.info/imageutil/images/large/sample_1.jpg';
$image = 'http://www.mikkonen.info/imageutil/images/small/output_1.jpg';
list($width, $height) = getimagesize($image);
if ($width >= $resizeWidth || $height >= $resizeHeight) {
    $resize = new ImageUtil($image);
    $resize->resize($resizeWidth, $resizeHeight)->save('tmp/output.jpg');
}

I will take a look at the wrong extension problem later.

boubouhkarim commented 10 years ago

OK, good luck ) :+1: & thanks for answering