从php生成器添加图像?
我想知道是否有可能添加像这样的链接从php生成器的图像从php生成器添加图像?,php,phpexcel,Php,Phpexcel,我想知道是否有可能添加像这样的链接从php生成器的图像parse/BarGen/generator.php?text=7600003223000939115260 $gdImage = imagecreatefromjpeg('uploads/simple.jpg'); // Add a drawing to the worksheetecho date('H:i:s') . " Add a drawing to the worksheet\n"; $objDrawing = new PHPEx
parse/BarGen/generator.php?text=7600003223000939115260
$gdImage = imagecreatefromjpeg('uploads/simple.jpg');
// Add a drawing to the worksheetecho date('H:i:s') . " Add a drawing to the worksheet\n";
$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setName('Sample image');
$objDrawing->setDescription('Sample image');
$objDrawing->setImageResource($gdImage);
$objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
$objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
$objDrawing->setHeight(150);
$objDrawing->setCoordinates('C1');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
来源:解决方案
function createImageFromFile($filename, $use_include_path = false, $context = null, &$info = null)
{
// try to detect image informations -> info is false if image was not readable or is no php supported image format (a check for "is_readable" or fileextension is no longer needed)
$info = array("image"=>getimagesize($filename));
$info["image"] = getimagesize($filename);
if($info["image"] === false) throw new InvalidArgumentException("\"".$filename."\" is not readable or no php supported format");
else
{
// fetches fileconten from url and creates an image ressource by string data
// if file is not readable or not supportet by imagecreate FALSE will be returnes as $imageRes
$imageRes = imagecreatefromstring(file_get_contents($filename, $use_include_path, $context));
// export $http_response_header to have this info outside of this function
if(isset($http_response_header)) $info["http"] = $http_response_header;
return $imageRes;
}
}
$gdImage = createImageFromFile('http://127.0.0.1:1234/dynexep/BarGen/generator.php?text=760000322300000939115260');
$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setName('Sample image');
$objDrawing->setDescription('Sample image');
$objDrawing->setImageResource($gdImage);
$objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
$objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
$objDrawing->setHeight(150);
$objDrawing->setCoordinates('C1');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
你试过了吗?大胆一点;)是的,但是作为$gdImage=imagecreatefromjpeg(),我遵循了一些例子。你有什么错误吗?@Fred ii-我有;]好的,很高兴听到。谢谢你的更新,干杯