I have a PHP site that requires PDF to image conversion, and we're obviously using imagemagick for it.
However, right now we're trying to move to different hosting, and it seems like I will not be able to install imagemagick package on the new hosting to do the same thing as we do now.
So the question is - is there any way to convert PDF to image with either pure PHP means, or with anything else that can be just popped into DOCUMENT_ROOT and do not need to be properly installed into the system.
This is a Linux system, but I have no idea what distribution, and I can't check as my rights in this system are really limited.
thanks
Alex.
"[...] requires PDF to image conversion, and we're obviously using imagemagick for it."
This is not obvious at all.
Because ImageMagick cannot convert PDF to images all by itself. It requires to use Ghostscript as its 'delegate'. So you may have installed ImageMagick, but not installed Ghostscript and it will not work.
Vice versa, you could have Ghostscript installed but not ImageMagick -- and you could still easily convert PDF to images. For instance, convert to JPEG with resolution 144 DPI (without specifying one, you'd get 72 DPI):
gs \
-o out.jpg \
-sDEVICE=jpeg \
-r144 \
in.pdf
Also, you are free to install Ghostscript wherever you want.
(BTW: I'd keep my hands off a hosting provider who does not offer a ImageMagick nor Ghostscript installation, let alone not allow to install it yourself...)
On linux systems statically linked things can work without external library dependencies. So if you could get/create a statically linked imagemagick executable, you could use it directly under docroot. Probably it isnt so trivial.
Or you could use remote sites for doing the conversion for you. Like:
http://pdf2jpg.net/
(For posting to upload forms like this curl will be usefull.)
Related
I'm trying to compile the imagick extension for Heroku, but I need it to look in the /app/bin folder for ImageMagick rather than the /usr/bin/ folder. I've used as much google-fu as I have, but I can't figure out how to build the imagick.so extension and have it point to a different folder.
From PHP, if I do shell_exec("which convert") it echoes the /app/bin version, but when I do Imagick::getVersion() it points to the /usr/bin/ version. This makes me think it's an issue in the extension.
I haven't ever had to make my own extension from source, so that could definitely be part of the reason. Anything you could do to point me in the right direction would be helpful.
Try with a php.ini file in the webroot, with the following contents:
extension_dir="/app/bin"
extension=imagick.so
You may have the wrong end of the stick. You don't compile the Imagick extension against the Image Magick executables but against the Image Magick libraries. i.e. if you're installing Image Magick through a package manager, you should be installing "ImageMagick-devel" not "ImageMagick"
You can then set the directory that Imagick should look for the Image Magick libraries for with the setting:
./configure --libdir=/usr/lib64 --with-php-config=/usr/local/bin/php-config
Or similar depending on where the libraries are installed, and then call make.
However if you're already compiling Imagick you might as well as also compile Image Magick from source.
Edit
If I was standing behind you, this would probably be solvable in 5 minutes. I suggest:
1) Find where the Imagick libraries actually are on your system - in particular find the libMagickWand-6.Q16.so file.
2) Make sure you're copying the Image Magick libraries that you want to use to the live server as well as the Imagick library, unless you're statically compiling it (which you probably aren't).
3) Rename the lib that you don't want it to be compiled against. See if compiling Imagick picks the right version up then.
4) Debug the ./configure script for Imagick - you can print stuff out like AC_MSG_RESULT(libs before $DEBUG_LIBS) as I had to do for one issue: https://github.com/mkoppanen/imagick/issues/8 and ensure it's picking the right version up when compiling.
5) Raise an issue at https://github.com/mkoppanen/imagick/ and get the Imagick guy to have a look.
I am trying to convert a jpeg image to a tiff image, however unsuccessful in doing it using PHP. Kindly help me out with this issue.
The main thing is that the imagemagick and exec() system() and related commands are blocked by the my service provider.
So provide me solution which deosnt use imagick and command tools for conversion.
For this action you need to have Imagemagic installed on your server (it is installed by default on an average web server) after you have Imagemagic support do the following:
$command = "convert /path_to_file/filename.jpg /path_to_file/filename.tiff";
exec($command);
if you dont have imagemagic install it from here:
http://www.imagemagick.org/script/index.php
is it possible to check the php imagick extension for ghostscript support?
for example if it is turned on / off, the ghostscript version used, etc.
which possibilities are there to get additional ghostscript / pdf details?
the only thing i've found so far is this (version of imagick lib itself):
http://php.net/manual/en/imagick.getversion.php
ps: no system calls are allowed (e.g. exec) from within php
I don't know much about imagick, but some things about imagemagick. My guess is that by reading this answer related to imagemagick could help you with imagick as well:
convert -list delegate | grep -Ei '(PDF|PS|EPS)'
(convert is one of the CLI utilities which are part of imagemagick.)
I would like to be able to convert videos to flv through the use of php and FFMPEG.
I was just wondering if anyone knew any good guides to setting up FFMPEG in a linux environment. I have found scripts showing how to use ffmpeg through exec() with php but I would like to know how to set everything up.
Also, I believe other software also needs to be installed in order for FFMPEG to work (ex. mp3 codecs?). If anyone could point me in the right direction, I would really appreciate it. I have been trying to search for ways to do this, but a lot of guides are outdated and some of the wget commands do not even work. Thanks in advance.
If you are looking for specific guides, would be useful to know which linux distribution you are using. As far as what else you need apart from ffmpeg, depends on what exactly you wish to be encoding. For example, if you wish to be able to encode xvid videos into flv, you'll need the Xvid codec.
I would recommend getting at least:
FAAD2
FAAC
LAME
yasm
x264
xvid
If you intend to encode mp4 videos with h264, you'd need qt-faststart as well, to move the meta data to allow immediate streaming.
(and personally prefer mencoder over ffmpeg)
Try this: http://wiki.collectiveaccess.org/index.php?title=Compiling_ffmpeg
I am a CollectiveAccess user, which uses ffmpeg for video processing. Those instructions were pretty much spot on when installed a new CA system on a fresh CentOS.
ffmepeg, and its dependencies, work best when compiled from latest source since the yum repositories lag a bit.
sudo apt-get install php5-ffmpeg
sudo apt-get install ffmpeg
That's should do the job (on ubuntu/debian at least)
I'm working on a package which includes rescaling of images in PHP. For image rescaling, PHP has the GD and ImageMagick libraries. Are those likely to be part of a given client's PHP install already?
Is there a "default" install of PHP, for that matter? By default, are either GD or ImageMagick included?
If neither is installed, should I have some sort of horrible fallback position of reading, rescaling, and saving GIFs, JPGs, and PNGs, or is it simple to add GD or ImageMagick to an existing install?
i can't remember when i've last seen a lamp hosting provider without GD. the imagemagick extension is not that widespread. if they run their server themself, they really should be able to activate one of it or both. in your place i'd build the full functionality with GD and a (probably reduced) imagemagick fallback. if they got neither, show them the basic concepts of the wheel and/or fire, they should be grateful.
PS: i encountered providers that deactivated certain GD functions (computationally too intensive on a shared hosting environment), like imagerotate and imagefilter.
GD is the easiet library to include in php.. it is "only" an extension, mainly included in php packages... the only operation needed is to activate the extension.
Regarding ImageMagik, it is more complecated, since the php imageMagik library is only an interface for the image magik software.
Using imageMagik require both software and php library installed
It is reasonable to expect the client to have the capability or an understanding of how to add the library. Are you selling software or servers maintenance?
If you're going for the whole "ease of use" angle, you'll want to package php with your app (and GD installed already), of which I'm not sure the legality. (but there's probably some way to get it done)
90% GD - 10% ImageMagick
Windows - Yes
Linux/MAC - No (but fairly easy to install)