Connecting Tech Pros Worldwide Forums | Help | Site Map

Do imagejpeg(), imagegif(), etc. compress images?

Phil Powell
Guest
 
Posts: n/a
#1: Jul 17 '05
I am using the imagejpeg() and the imagegif() (also imagepng(), etc.)
commands that will write an image Object back into an existing image
in a directory.

Everything works fine, except that when I compare image filesizes
between the original and the one created via imagejpeg(), the size of
the latter is 50% of that of the former.

example: myimage.jpg = 29K
imagejpeg($newImage, 'myimage2.jpg');
myimage2.jpg = 15K

However, everything about myimage.jpg and myimage2.jpg are completely
identical in every other way: same height, same width, same MIME type,
they look EXACTLY alike in the browser!

is there some compression going on that I am not aware of with
imagejpeg()?

Thanx
Phil

Agelmar
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Do imagejpeg(), imagegif(), etc. compress images?


Straight out of the manual (http://www.php.net/imagejpeg), the optional 3rd
praramter controls quality (compression).

Phil Powell wrote:[color=blue]
> I am using the imagejpeg() and the imagegif() (also imagepng(), etc.)
> commands that will write an image Object back into an existing image
> in a directory.
>
> Everything works fine, except that when I compare image filesizes
> between the original and the one created via imagejpeg(), the size of
> the latter is 50% of that of the former.
>
> example: myimage.jpg = 29K
> imagejpeg($newImage, 'myimage2.jpg');
> myimage2.jpg = 15K
>
> However, everything about myimage.jpg and myimage2.jpg are completely
> identical in every other way: same height, same width, same MIME type,
> they look EXACTLY alike in the browser!
>
> is there some compression going on that I am not aware of with
> imagejpeg()?
>
> Thanx
> Phil[/color]


Closed Thread