Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to output exec to variable

Tags:

php

image

svg

exec

I have this command that will convert SVG to image:

exec("convert -size 400x400 test.svg test.png", $out, $rcode);

But it works with fiels, when I actually need to work with DOM variables.

how to get the resulting PNG to $variable insted of file (in PHP) please.

like image 387
Israel Gav Avatar asked Sep 06 '15 16:09

Israel Gav


People also ask

Is it possible to assign result value from exec function to variable?

The capturing and assigning result value from EXEC function to a variable is supported in SQL Server versions i.e. 2000, 2005, 2008, 2008R2, 2012, 2014 or higher. Here I am making use of Microsoft’s Northwind Database. The download and install instructions are provided in the following article.

How to insert resultset from exec into a table?

The resultset from an exec can be put into a table directly: declare @tmp_select char(500) set @tmp_select = 'select count(*) from dptest'. CREATE TABLE ResultSet (mycount int) INSERT INTO ResultSet. EXEC @tmp_select. To put it into a variable from there, you'd have to add another select.

How to execute a dynamic SQL statement with input parameters?

SELECT @cmd = 'INSERT INTO #number SELECT COUNT (*) FROM CONTACT2 WHERE ' + @fldname + ' IS NOT NULL ' Execute dynamic SQL statement using sp_executesql system stored procedure, if you want a output to a variable. It allows input parameters as well as output parameters. I support sp_executesql approach.

Which version of SQL Server supports capturing result value from exec?

The capturing and assigning result value from EXEC function to a variable is supported in SQL Server versions i.e. 2000, 2005, 2008, 2008R2, 2012, 2014 or higher. Here I am making use of Microsoft’s Northwind Database.


1 Answers

This is probably what you are looking for:

<?php
$output = shell_exec("convert test.svg png:-");
echo $output;

Depending on your local setup you might have to specify the absolute path to your convert utility. Also the path to the file to be converted must be resolvable, again an absolute path is a safe bet at first.

like image 167
arkascha Avatar answered Oct 21 '22 22:10

arkascha