image loses alot of quality

May 21, 2008 at 12:18 PM

When I add an image (with out resizing) it looses allot of quality it becomes really blurry....

If i insert or copy and paste the image file into an excel sheet on my own quality is nt lost, what is causing the quality to degrade using the PHPEcel class?

Here is code:
   $objDrawing = new PHPExcel_Worksheet_Drawing();

I have tried using a gif, jpg, png, and tif file formats all produce the same loss in quality...

May 21, 2008 at 12:58 PM
Are you creating XLS or XLSX files?
May 21, 2008 at 2:12 PM

maartenba wrote:
Are you creating XLS or XLSX files?

I am using XLSX.  Also my test (not apples to apples I know) I am using Excel 2007 and can paste or insert the same image file no problems.

Thanks for the help.

May 23, 2008 at 2:27 AM
Is this a known issue?  would you like the files to duplicate the issue?  I really need to know about this,  I have looked through the source and I can't see where it would downgrade image quality....  I really need to get this one figured out,  as this whole thing in my project is well really cool (as a user can choose their export format) but in the end with out the logo we can't use it :(

Please let me know if this is a known issue,  or if you know how to fix it,  or where in the code it might cause the image to loose quality....

May 23, 2008 at 6:41 AM
Can you post an example to reproduce this?
May 23, 2008 at 7:53 AM
If you right click on googles logo and save it as "GoogleLogo.gif" to your images folder,  you can reproduce the problem with this code:

$objPHPExcel = new PHPExcel();

//add the logo to the excel file.
$objDrawing = new PHPExcel_Worksheet_Drawing();

//call the files needed and out put it to the client
 $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);

Jul 8, 2008 at 1:14 PM
So is it fixible? :)

It seems like image resizing, type (gif, png, jpg, ...) or output format are not important.
I tried to use pure *.png image and then resized. Also I used Excel5 writer with *.xls file extension and Excel2007 writer with *.xlsx file extension and result was the same.

When i open generated excel file and add the same image manually (by going Insert->Picture->blah blah blah) - quality seems to be ok.

Somehow image is loosing quality :(. Maybe it is OpenXML API problem?

Jul 9, 2008 at 9:28 AM
Edited Jul 9, 2008 at 9:46 AM
OK, here it goes... (Part I)

I generated *.xlsx file with image using excel writer Excel2007. Image was blurry (as usual). Then I inserted the same image again by hand using Excel. So in my *.xlsx document i had 1 blurry image and 1 normal image.

Then i changed *.xlsx file extension to *.zip, opened it and tried to search for images. The only image i found was in\xl\media folder. It was in its original quality.

So, i made a copy of the archive and opened it with excel, removed blurry image and checked\xl\media folder again. Image was there.
I made another copy of the archive and opened it with excel, removed newly inserted image (not blurry one) and checked\xl\media folder again. Image was there.
Then I made another copy of the archive and opened it with excel, removed both images and checked\xl\media folder again. There were no images.
Conclusion: "blurrisity" was not the image's quality's fault, as the excel use the same normal quality image differently in the excel file. It is the excel, which was somehow instructed to show blurry image.

Here we go again.... (Part II)

The only place where the name of the image was mentioned is the\xl\drawings\_rels\drawing1.xml.rels file. Name of the image was assigned to some "relationship" variable there. "Relationship" variable's name was rId1.
So then i looked for a places where rId1 was mentioned in. Found two places, both in the same file\xl\drawings\drawing1.xml.
Then, by comparing found two nodes of code, i noticed, that by commenting <a:scene3d>...</a:scene3d> section, blurry image become normal again :).


So, i tried to comment those <a:scene3d> tags generating code and it worked fine then. Not sure what theese tags do, but i like my excel documents better without them ;). It were lines 266-287 in PHPExcel/Writer/Excel2007/Drawing.php file. PHPExcel version 1.6.2. Starting line text: $objWriter->startElement('a:scene3d');

Dont know how to fix this in excel writer Excel5, but FlexIDX's project should be fine with this.. same as the mine ;)

Jul 9, 2008 at 1:31 PM
Will be fixed in (for Excel 2007)