views:

34

answers:

1

Hello

I am trying to functions: 1. imagecreatefrompng 2. imagepng

my php code looks like this:

<?php
ini_set('memory_limit', -1);

try{
    //if(!$image=imagecreatefromjpeg('zee3.jpg')){
   if(!$image=imagecreatefrompng('leo.png')){
      throw new Exception('Error loading image');
   }
   imagepng($image, 'leoAfter_9compression1.png', 9);
   // free up memory
   imagedestroy($image);
}
catch(Exception $e){
   echo $e->getMessage();
   exit();
}

ini_restore('memory_limit');

?>

The image leo.png a 3MB file

But after running the code leoAfter_9compression1.png image come out to be 1.7MB file. but it is getting cropped. Which i do not want.

And i am unable to understand why is that happening.

Can someone tell me the reason to image getting cropped, and how can i avoid it.

If someone wants to test for the image i am talking about, search "image" leo.png on google. it will the first image on the search. The image gets cropped as well as distorted. But i tried the same algorithm for a different image, and its works fine on that.

Regards Zeeshan

+1  A: 

It shouldn't, check the original image.

Alix Axel
It is doing it..
Zeeshan Rang
It may be due to a bug in ImageCreateFromPNG() but I highly doubt it, any chance you can upload the leo.png image?
Alix Axel