I want to crop an image to a specified pixel region. I'd like to use the gm module from https://github.com/aheckmann/gm.
I am running Linux Mint 13 and node.js v0.9.4pre.
I am running into an error that sounds like graphicsmagick doesn't know about jpegs:
Error: Command failed: gm convert: No decode delegate for this image format (./assets/images/temp/2aadd4379e1cf2b59429994270db2a8a.jpg)
Sure enough, gm convert -list formats shows no jpeg delegate:
<snip>
IPTC P rw- IPTC Newsphoto
IPTCTEXT P rw- IPTC Newsphoto text format
IPTCWTEXT P rw- IPTC Newsphoto text format
K25 S r-- Kodak Photo RAW
<snip>
graphicsmagick has a ftp folder containing source code for delegates (with a readme.) So I downloaded, untarred, and installed jpegsrc.v6b.tar.gz as suggested in both the install document that came with my source files.
I'm pretty sure the jpeg library installed cjpeg and djpeg and perhaps other stuff. However there is no make uninstall or manifest that I found. I haven't tried installing any other versions of the jpeg library over this one. I uninstalled and rebuilt graphicsmagick after installing the jpeg library.
Still, there is no JPEG delegate listed in gm convert -list formats.
I am migrating from Imagemagick which never had any problems resizing jpegs, even without my installing this library.
What must I do to get graphicsmagic to handle jpegs?
Here's how I am invoking gm:
var gmagic = require('gm');
gmagic(cfg.tmpPath)
.crop(h,w,x0,y0)
.write(cfg.croppedPath, function(err){
if(err){ done(err) }
else { done(null, cfg.croppedPath) };
});
Here are the commands I used to install the jpeg library and graphicsmagick:
$ cd ~/source
$ wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
$ tar -xzvf jpegsrc.v6b.tar.gz
$ cd jpeg-6b
$ ./configure
$ make
$ sudo make install
$ cd ~/source
$ wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/1.3/GraphicsMagick-1.3.18.tar.xz
$ tar -xJvf GraphicsMagick-1.3.18.tar.xz
$ cd GraphicsMagick-1.3.18
$ ./configure
$ make
$ sudo make install
$ npm install gm
I found a successful workaround by telling the gm library to use imagemagick binaries instead of default graphicsmagic binaries:
var gmagic = require('gm');
var imagic = gmagic.subClass({imageMagick: true});
...
imagic(cfg.tmpPath)
.crop(h,w,x0,y0)
.write(cfg.croppedPath, function(err, stdout, stderr, command){
if(err){ next(err) }
else { next(null, raft) };
});
Given that you are using Linux Mint, the best solution for GraphicsMagick to find libjpeg is to install the libjpeg development package (libjpeg-dev), re-run the GraphicsMagick configure script, rebuild, and install. Be sure to add -dev packages for libraries supporting other formats you are interested in.
If you want to use the libjpeg installed from source code, then you will need to add the options LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include to the GraphicsMagick configure script invocation. Be aware that Linux Mint may come with a different libjpeg than jpeg 6b (e.g. jpeg 8 or libjpeg turbo) and it is best not to have duplicate libraries on the system.
I realise this is strictly a Linux question, but maybe this will help someone...
On Mac, I used HomeBrew instead. Just run these 3 lines (the chown line was necessary for me, you might want to try without first):
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
sudo chown -R $USER:admin /usr/local
brew install graphicsmagick
If it complains about jpeg libraries being unlinked, run brew doctor + follow instructions to link any missing "kegs".
And if something gets messed up and you want to start over (see https://stackoverflow.com/a/17846596/188926):
brew uninstall imagemagick graphicsmagick libpng jpeg
brew cleanup -s
brew install graphicsmagick
Related
I'm trying to find the dimensions of the images in a production machine.It returns error.
Could not execute GraphicsMagick/ImageMagick: identify "-ping" "-format" "%wx%h" "uploads/userPhoto-1499669685192.png" this most likely means the gm/convert binaries can't be foundsize==undefined
But it is working fine in local machine and I have already uploaded modules in production machine which are same as local machine.
According to source code for gm, this error happens when spawn (function to start a process) returns ENOENT, which is the low-level error for "no entry", meaning the required program was not found in $PATH for the running node process (I mean it might be present but you still need to check environment of running process).
So it is a simple installation issue of the required components. Local machine has all af them, but not your production machine. You said you have "already uploaded all modules" (I think you mean all npm modules), but that is not enough, the gm module relies on one of GraphicsMagick or ImageMagick.
Quote from main page for gm:
First download and install GraphicsMagick or ImageMagick.
Probably graphicsmagick / imagemagick is not installed correctly, download GraphicsMagick or download ImageMagick, if your are using Ubuntu, these commands are useful.
sudo add-apt-repository ppa:dhor/myway
sudo apt-get update
sudo apt-get install graphicsmagick
sudo apt-get install imagemagick
and I list a few examples of the identify command here to illustrate its usefulness and ease of use.
To get started, lets identify an image in the JPEG format:
$ magick identify rose.jpg
> rose.jpg JPEG 70x46 70x46+0+0 8-bit sRGB 2.36KB 0.000u 0:00.000
Or to get the print size in inches of an image at 72 DPI, use:
$ magick identify -format "%[fx:w/72] by %[fx:h/72] inches" document.png
> 8.5 x 11 inches
You can find more options and information from this link.
This is old, but I have no problems in Fedora, but on Ubuntu (I'm using Travis CI):
This don't work
sudo apt-get -y install imagemagick
This works:
sudo apt-get -y install graphicsmagick
This worked for me:
Open up command prompt as admin, navigate to project folder, and type "grunt" at command prompt.
If you get an error that says "grunt hasn't been installed locally to your project", make sure both grunt and grunt-cli are installed.
If you are on Windows and still get an error, reinstall via ImageMagick.exe:
Visit http://www.imagemagick.org/script/download.php#windows and download the exe file.
Run it on your local machine.
Select "Install legacy utilities (e.g. convert) on 'Select Additional Tasks'.
After installation is complete, type "grunt" from your project directory in cmd.
If you installed ImageMagick then you have to create a symlink to gm in an exposed directory like /usr/local/bin on Mac from your magick binary
Executing this should help.
ln -s /path/to/bin/magick /path/to/bin/gm
gm should be placed in the path exposed to the terminal.
I have never used ffmpeg on my Ubuntu Linux 12.04 (Precise Pangolin) box until now. Typing 'ffmpeg' at the command prompt revealed that ffmpeg 0.8.17 (listed as ffmpeg 0.8.17-4:0.8.17-0ubuntu0.12.04.2) was installed. Seeing as I need to convert h.265 to h.264, an update was obviously required.
Following posted instructions, I installed a ream of packages:
$ sudo apt-get install faad libmp4v2-dev libfaac0 libfaac-dev
libxvidcore4 libxvidcore4-dev liba52-0.7.4 liba52-0.7.4-dev libx264-dev
libgsm-tools libogg-dev libtheora-bin libfaad-dev libvorbis-dev
libtheora-dev libdts-dev git-core yasm texi2html checkinstall
followed by
$ sudo apt-get purge ffmpeg
in order to get rid of the old stuff from the original repo.
Downloaded the latest ffmpeg, and a ."/configure; make; sudo make install" later, I should be in business.
Except that typing 'ffmpeg' at the prompt still fired up the old version. A quick look revealed that the old ffmpeg binary was still sitting in /usr/bin with the new one being installed in /usr/local/bin. But ffmpeg is no longer listed as an installed package, and sudo apt-get remove ffmpeg tells me that "Package ffmpeg is not installed, so not removed".
Running /usr/local/bin/ffmpeg directly works, however then fails in an Unknown encoder 'libx264' error. Which is puzzling because the package libx264-120 is installed and /usr/lib/i386-linux-gnu/libx264.so.120 (with the appropriate symlink to /usr/lib/i386-linux-gnu/libx264.so) does exist.
Maybe I've been looking at this for too long, because I'm sure this is a simple issue but I just can't see it.
Can someone please hand me the stupid had and point out why I deserve to wear it?
Tnx!
You should find out which package provides this old binary in /usr/bin by running
dpkg -S /usr/bin/ffmpeg
Then remove that package in turn.
Note that if that file is a symlink, esp. to /etc/alternatives, you should follow the trail of symlinks and then run the above command on the actual binary.
I'm trying to make some Networkx Graphviz graphs.
After running: pos = nx.graphviz_layout(G, prog = 'sfdp'). An error occured, saying:
Error: remove_overlap: Graphviz not built with triangulation library
After some Google research I found that GTS is the problem. Bug report stated:
The Graphviz package is built --without-gts. This is bad news for sfdp, which complains “Error: remove_overlap: Graphviz not built with triangulation library” and fails to produce the beautiful output it creates when compiled --with-gts
Looking at comments ( on bug report ), someone said that the upstream sources for Graphviz are kept at link but I couldn't find new versions to download.
On package list I have the latest one (2.36 for trusty).
Anyone else having problems with sfdp?
Any help will be greatly appreciated!
For the ubuntu users, this is how I got grapvhiz to work on 16.04,compiling graphviz-2.40.1 from source:
In a first step , GTS needs to be installed , as graphviz looks for the gts.pc file.
Running
apt-file search gts.pc
Informs me I have to install 'libgts-dev' :
sudo apt install libgts-dev
next make pkg-config aware of the files:
pkg-config --libs gts
pkg-config --cflags gts
run configure to link in the gts library:
./configure --with-gts --prefix ~
make
make install
SFDP no longer throws the error 'Error: remove_overlap: Graphviz not built with triangulation library'
The command line codes for the pkg config I modified from this answer.
I know the question is for Ubuntu, but in case someone is having the same problem on macOS using homebrew the following worked for me:
brew reinstall graphviz --with-gts
I might have it working for Ubuntu 14.04, YMMV
Download the following graphviz packages directly from https://packages.debian.org/search?keywords=graphviz
graphviz_2.38.0-13_amd64.deb
libcgraph6_2.38.0-13_amd64.deb
libgvc6_2.38.0-13_amd64.deb
libgvpr2_2.38.0-13_amd64.deb
libltdl7_2.4.6-0.1_amd64.deb
python-pygraphviz_1.3.1-1_amd64.deb
I used version 2.38.0-13 from the stretch(testing) group.
You will need to remove the 32bit libltdl7 if present:
sudo apt-get remove libltdl7:i386
Install the packages directly with
sudo dpkg -i graphviz_2.38.0-13_amd64.deb
sudo dpkg -i libcgraph6_2.38.0-13_amd64.deb libgvc6_2.38.0-13_amd64.deb libgvpr2_2.38.0-13_amd64.deb libltdl7_2.4.6-0.1_amd64.deb
You can expect dependency errors. I cleared them with:
sudo apt-get install -f
And then re-install
sudo dpkg -i graphviz_2.38.0-13_amd64.deb
sudo dpkg -i python-pygraphviz_1.3.1-1_amd64.deb
The error no longer appeares though I would be hard pushed to say the graphs are any better.
I'm trying to install ImageMagick but everytime, the libpng isn't used.
When I'm running
identify -version
png does not appear in the list.
I'm retrying to install properly ImageMagick with these commands:
./configure --enable-shared
make libdir=/usr/lib64
make libdir=/usr/lib64 install
./configure --enable-shared=yes --x-libraries=/usr/lib64 --without-perl
make
make install
after in found libpng in /usr/lib64 on my system.
But after
make libdir=/usr/lib64 install
I always have this
DELEGATES = bzlib mpeg freetype jpeg lcms ps tiff x zlib
and no png is listed.
I'm still in trouble. I don't know where is my mistake.
I'm working on CentOS 6.6.
Try to add --with-modules to your configure options.
Also, inspect the output of your ./configure ... command for error and warning messages.
Most Linux distros package the runtime libraries separately from the compile-time header files. You may need to install an additional package named libpng-dev or libpng-devel to get the header files onto your system which are needed to compile ImageMagick with PNG support.
I am trying to get CRFSuite to work on Mac OS X. The author only has binaries for Windows and Linux, but does provide the source package. I am guessing I need to somehow compile the source into a Mac OS X executable? This I have no idea how to do. I did some research on this, but nothing actually works. I also asked a PhD student at the university specifically this problem--he told me it would be very difficult.
I have been able to get CRFSuite to work by using WineSkin, but that's a workaround and not a real solution.
Ideally when I open the Terminal I should be able to invoke CRFSuite by just typing "crfsuite" and not jumping through hoops to pipe commands to a WineSkin Windows Terminal.
It's easy with homebrew.
First go to homebrew website - here and install it. It is very simple.
Then do the following in Terminal:
brew tap brewsci/science
brew install crfsuite
If anything goes wrong, use
brew doctor
Once you are up and running, I find it a good idea to occasionally do the following to upgrade brew itself and the installed packages:
brew update
brew upgrade
There are lots of gret, up-to-date packages that are so easy to install using homebrew, I use the following:
ant
basex
cmake
coreutils
exiftool
exiv2
faac
ffmpeg
fontconfig
freetype
gawk
gd
gettext
ghostscript
gnu-sed
gnuplot
ilmbase
imagemagick
jasper
jbig2dec
jhead
jp2a
jpeg
lame
leptonica
libpng
libtiff
libtool
lighttpd
little-cms2
lua
lynx
mad
netpbm
opencv
openexr
openssl
p7zip
parallel
pcre
perlmagick
pipebench
pipemeter
pkg-config
platypus
proftpd
pv
qt
readline
redis
sleuthkit
sox
sqlite
sqlitebrowser
tag
tesseract
tree
wget
x264
xvid
xz
If you want to look for additional packages, just use:
brew search <search string>