PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Oct 20, 2019 6:38 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Jan 27, 2008 10:40 pm 
Offline
Forum Newbie

Joined: Sun Jan 27, 2008 10:24 pm
Posts: 2
Please forgive me if this has been asked answered or considered trivially basic but I'm very curious.

Why is a jpeg from my digital camera (7 gigapixels, 1.5 Mb) three times larger than an image resulting by copying it with GD.

For example, the following code:

$im = ImageCreateFromJPEG("file1.jpg");
$width = ImageSx($im);
$height = ImageSy($im);
ImageJPEG($new, "file2.jpg");

will open a 1.5 Mb jpeg file, gets its image data, and copies it into a new jpeg file only 449 kb in size.

I'm assuming, the jpeg display information of the first file only accounts for 1/3 the file's information and that the resulting jpeg still has every bit of display information as the first but that all the raw camera information was also stored in the first file but not copied to the second.

I'm I at all close?

I'm just curious but I'd like to knew if an image reproduced with GD is any "less" than the original. Also I'm am now very curious about what the heck is jpeg information anyway.

-cheers
woozy


Top
 Profile  
 
PostPosted: Mon Jan 28, 2008 2:08 am 
Offline
DevNet Master
User avatar

Joined: Wed Dec 06, 2006 5:14 pm
Posts: 3635
Location: Toronto, Canada
jpeg is a lossy format - it's likely that the compression on your camera is set very low to keep image quality high, but the default settings for the PHP function are much more aggressive.


Top
 Profile  
 
PostPosted: Mon Jan 28, 2008 2:17 am 
Offline
Tranquility In Moderation
User avatar

Joined: Sun Feb 06, 2005 8:18 pm
Posts: 5001
Location: Indiana
Also, the exif data in the jpeg most likely contains a thumbnail image with a pretty decent size. Other comments and info in the exif data could take up significant room. That combined with kierans explanation makes a lot of sense.

_________________
- A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group