Images and PHPEXCEL

Topics: Developer Forum, Project Management Forum, User Forum
Jan 14, 2013 at 10:11 AM
Edited Jan 14, 2013 at 10:12 AM

Hi Everyone, back for more help!!

So heres the situation, I have attached my mysql database to phpexcel, so when I export I get everything, now I have added the OBJdrawing method do convert my image_link to the image in excel works perfectly.

I work on a mac just for more in depth knowledge on what im using

So when I export the spreadsheet it's around 22MB okay, still no problems there works absolutely fine.

Now when I go to compress it, it compresses to a rather impressive 918kb, AND STILL WORKS!?

So I was wondering is there a compression method on images, or can I use this GD feature?

From the documentation:

You can also add images created using GD functions without needing to save them to disk first as In-Memory drawings.

//  Use GD to create an in-memory image

$gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream');

$textColor = imagecolorallocate($gdImage, 255, 255, 255);

imagestring($gdImage, 1, 5, 5,  'Created with PHPExcel', $textColor);


//  Add the In-Memory image to a worksheet

$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();

$objDrawing->setName('In-Memory image 1');

$objDrawing->setDescription('In-Memory image 1');









Now when I tested this out I tried changing


$gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream');




$gdImage = 'my_imageLink'


but didn't seem to work?

With this being helped and LWOL currently helping me understand client side and phpexcel I feel I can make quite an interesting plugin.


Thank you for readin.

Jan 27, 2013 at 4:56 PM
(this is not me, but my twin;-)
imagecreatetruecolor returns a GD resource, if you put a string in $gdImage, at some point or another, it will not work...
Therefore, if you want to use this technique, employs one of the GD imagecreatefromXXX functions where XXX is gif, jpeg, etc., depending on the format of your source image.
Jan 27, 2013 at 5:16 PM

Okay brilliant, I was researching into GD and php so I got it a bit better.

this discussion can be closed now :D