I need to extract the icon (.ico file) out of an executable (.exe).
I need it for PHP on Windows. Any Ideas?
I originally thought that ImageMagick will extract icons from .exe files. However, it seems my memory is failing me.
Instead, since you are prepared to accept the use of exec I think the quickest and easiest solution will be to use a tool like ResHacker. The can be driven in command-line mode. Then if you need to convert from .ico to .png, as per your last question, you can reach for ImageMagick.
Related
I need to convert AMR audio file to MP3. How can I make it in PHP without FFMPEG (i have no permissions to install it on the server). Please help me.
Use SoX - the Swiss Army knife of sound processing. Very easy to use.
It is a command line tool not a PHP library so to use from PHP you need to execute a shell command and get the result with in your code. I have used it with in few projects.
Example with PHP:
<?php
exec('sox /mypath/my_audio.amr /mypath/my_audio.mp3');
?>
SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various formats of computer audio files in to other formats. It can also apply various effects to these sound files, and, as an added bonus, SoX can play and record audio files on most platforms.
SoX is very mature project! Here is the link: http://sox.sourceforge.net/
Here are some examples I googled for you:
http://www.thegeekstuff.com/2009/05/sound-exchange-sox-15-examples-to-manipulate-audio-files/
Just use ffmpeg. You can simply download a binary of ffmpeg (look for "static builds"), and then point your script to the binary. There is no need to install it so there should be no permission issues.
AFAIK there is no way, at least without other command line utilities. You could try using mplayer, but I guess the situation here is the same as with ffmpeg. :)
You could of course upload the executable and run it through PHP if your host's policies allow this (safe mode, SELinux).
Simple answer: You can't convert audio files in pure PHP. I would suggest you to create/ search for a web-service to accomplish that task.
I was wondering if anyone had any advice for encoding a user uploaded .wav file to a .mp3 extension. I would like to build a PHP solution if possible. Can I call the command line LAME encoder via PHP once a file has been uploaded? Is there a better option?
Thanks!
Go ahead and call LAME. No chance of a better option existing, even more so if you take the encoder quality into account.
The easiest way to call into an external binary is exec, while for the best integration over the encoding process you might want to use proc_open.
I wrote a wrapper for LAME that provides convenient interface to encode wav file(s). The library is available here: https://github.com/b-b3rn4rd/phplame
I do this, I downloaded and installed ffmpeg with libmp3lame.
In your code do this:
$commandOutput = shell_exec('ffmpeg (or path to your ffmpeg file) -i file.wav file.mp3')
This question already has answers here:
Is there a PDF parser for PHP? [closed]
(7 answers)
Closed 8 years ago.
My question is that i want to open documents(pdf,doc,docx,txt) in browser page using php (without using google docs viewer) can any one help me?
Some of these are doable. Some, not so much. Let's tackle the low-hanging fruit first.
Text files
You can just wrap the content in <pre> tags after running it through htmlspecialchars.
PDF
There is no native way for PHP to turn a PDF document into HTML and images. Your best bet is probably ImageMagick, a common image manipulation program. You can basically call convert file.pdf file.png and it will convert the PDF file into a PNG image that you can then serve to the user. ImageMagick is installed on many Linux servers. If it's not available on your host's machine, please ask them to install it, most quality hosts shouldn't have a problem with this.
DOC & DOCX
We're getting a bit more tricky. Again, there's no way to do this in pure PHP. The Docvert extension looks like a possible choice, though it requires OpenOffice be installed as well. I was actually going to recommend plain vanilla OpenOffice/LibreOffice as well, because it can do the job directly from the command line. It's very unlikely that a shared host will want to install this. You'll probably need your own dedicated or virtual private server.
In the end, while these options can be made to work, the output quality is not guaranteeable. Overall, this is kind of a bad idea that you should not seriously consider implementing.
I am sure libraries and such exist that can do this. Google could probably help you there more than I can.
For txt files I would suggest breaking lines after a certain number of characters and putting them inside pre tags.
I know people will not be happy about this response, but if you are on a Linux environment and have pdf2html installed you could use shell_exec and call pdf2html.
Note: If you use shell_exec be wary of what you pass to it since it will be executed on the server outside of PHP.
I thought I'd just add that pdfs generally view well in a simple embed tag.
Or use an object so you can have fall backs if it cannot be displayed on the client.
I am looking for a way to embed album art in a mp3 file with PHP, either through a some kind of PHP script or through exec() and a Linux command.
PHP supports setting ID3 tags, but it looks like it does not support images.
If you want to add image you can make use of the eyeD3 Linux command with --add-image option.
So my host provides ImageMagick on the server, but no MagickWand or IMagick API for PHP. I can do operations with the PHP exec command to manipulate images. But that requires full path file names to work, and I want to pull my images from my MySQL database. Will I have to have pull them out of the database and put them to a file everytime I want to do this? Any recommendations?
One option is to run the imagemagick process using proc_open() and write/read to/from the created process' stdin/stdout.
To have imagemagick read from stdin, you just give a dash '-' as input file. Specify /dev/stdout as the output file. Your call to image magick should look something like:
convert -scale 150x100 - /dev/stdout
Use fwrite and fread on the pipes created by proc_open to write input to imagemagick and read output back.
I haven't tried it, but I guess this should work.
If the only ImageMagick available to you can only operate on files (which is how I read your first sentence), then you will indeed have to make files from your MySQL blobs to use ImageMagick on them (and remember to clean things up afterwards). My recommendation might be to switch to a better hosting service, but I assume you have your reasons to stay with that one.
have you tried phMagick ?